Hi,
I teach a software development class where students progressively build a web application in Django, and eventually deploy it to Google App Engine. This is the second year we do this sequence of homeworks and, last year, we were able to successfully deploy the apps by essentially following the official "Running Django on the App Engine standard environment" instructions.
When updating the homework this year, we were able to complete all the steps but, when we got to the very end (after setting up the database and deploying the app), we keep getting the following error:
connection to server on socket "/cloudsql/rabble-borja:us-central1:rabble/.s.PGSQL.5432" failed: Connection refused Is the server running locally and accepting connections on that socket?
Furthermore, the Cloud SQL logs show the following:
Cloud SQL connection failed. config invalidated after TLS handshake failed, error = certificate had CN "", expected "rabble-borja:rabble"
Please note that the app works correctly when we run it locally and use Cloud SQL Auth Proxy to connect to the database. We're able to initialize the database, upload a fixture with some test data, and run the app without any issues. So, the database itself is definitely running, has the correct data and user, etc. The issue seems to be specifically when the app deployed on GAE tries to connect to the database.
We've tried several things to debug this issue:
Any suggestions on what could be going on?
Hi @bsotomay,
I appreciate you provided a thorough breakdown of the issue, including the logs and the steps you've taken to debug—these details are incredibly helpful. I also saw @ms4446's response to your related post here: Unable to connect to Cloud SQL PostgreSQL database from Django, and noticed that you've submitted feedback about the issue as well— thanks for doing that.
I attempted to reproduce the issue by following the same Django on App Engine tutorial, but I used Cloud Shell instead of the local CLI, together with Cloud SQL Enterprise. I also encountered the same error, specifically on Run the app on your local computer, Step 5: Start the Django web server. This confirms what ms4446 pointed out in your other thread—namely that it’s a TLS handshake issue.
In addition to what he mentioned, you're welcome to report this behavior through the following channels:
Include steps to replicate, configuration settings, screenshots, and other details of the issue to help us investigate. While there isn’t a specific timeframe for resolution, once we've fixed an issue in production we'll indicate this and then update and close the bug.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.