Search code examples
pythonmysqlpython-2.7google-app-enginegoogle-cloud-sql

GAE Cloud SQL connection timed out


When I try to run the database locally and the server is asking for requests everything works fine but when I try to upload the database and the server to GAE Im always getting this error:

OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'xx.xxx.xx.xx' ([Errno 110] connection timed out)")

Im trying to accomplish a stable connection without having to run mysql on my local machine.

Thanks for anyone helping.


Solution

  • You can indeed use Cloud SQL from App Engine without having to run your own MySQL instance. To do so, you can have a look at the information in the official documentation.

    Make sure that you are configuring your environment variables correctly (you can do so directly from the app.yaml configuration file) and importing the MySQLdb library, as explained in the corresponding section in that same page.

    There you will find some sample code and also additional information regarding how to test your application both in the development and production environments.