I fixed the Cloud SQL connection issue


In last week’s post I talked about a connection issue that I was experiencing in my capstone project. I was unable to make calls from our server, which is hosted on Google App Engine, to our database, which is hosted on Google Cloud SQL. And today, after days of trial and error, I finally fixed the issue. This is great news, because resolving this issue unblocked our backend endpoint development.

The solution required a lot of steps.

I started with the test environment first. To start, I had to provide the Google App Engine application authorization to the Cloud SQL database. From there, I had to create service accounts that allow the appropriate permissions for the application. Then, I had to setup a TCP connection using a cloud SQL proxy to be able to access the database when running my app locally. After that, I had to learn how to use Knex, a SQL query builder that allows connection pooling via a unix domain socket. Lastly, I setup various environment variables, started the proxy, and was finally able to make calls from the server to the database.

Next, was the production environment. With the test environment finally working, the production environment was much quicker. I ensured that I had the appropriate credentials loaded in my configuration. Then, I deployed the server to Google App Engine. I then tested out the production endpoints, and successfully made calls to the database.

This issue made this past week incredibly frustrating. But I learned a lot about connections via cloud applications and database. And, I built some character along the way.

I’m sure there will be many more frustrating challenges that I will face during my professional career. So this was just a taste of what is yet to come…

(but hey, at least I solved this issue. hooray!)

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *