Friday, April 9, 2021

[google-cloud-sql-discuss] Re: "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")

Looking at some public forums [1][2] , I found some valid reasons why you may experiencing this error.  Mostly related to your MySQL server only listening the localhost interface or db user's privileges. 

[1]https://stackoverflow.com/a/1420862/7046224
[2]https://discuss.erpnext.com/t/cant-connect-to-mysql-server-on-u-local-host-error-111-connection-refused/41047/2
On Wednesday, April 7, 2021 at 11:45:36 AM UTC-4 stran...@gmail.com wrote:
My application is running.
I can run it and connect locally when point to ip on CloudSql
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://{}:{}@{}/{}".format(db_user,db_pass,db_host,db_name)

When I change it and run it on server:
SQLALCHEMY_DATABASE_URI = "mysql+pymysql:///unix_socket=/{}/{}".format(db_user,db_pass,db_name,db_socket_dir,cloud_sql_connection_name)

I got:

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/a76f2a49-ace1-43c1-bb1e-8e70d8b8f346n%40googlegroups.com.

No comments:

Post a Comment