Tuesday, April 6, 2021

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

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/8442cdee-54b0-4089-a333-30066eb41d82n%40googlegroups.com.

No comments:

Post a Comment