Friday, May 5, 2017

[google-cloud-sql-discuss] Re: ENOENT accessing socket

Is this error specific to nodejs?

I am seeing a similar error in Python 3.5. Could this be related (Is there a variable that I might need to set Python 3 as well?)

/env/lib/python3.5/site-packages/pymysql/connections.py", line 901, in connect sock.connect(self.unix_socket) FileNotFoundError: [Errno 2] No such file or directory

Traceback (most recent call last): File "/env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 2138, in _wrap_pool_connect return fn() File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 387, in connect return _ConnectionFairy._checkout(self) File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 766, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 516, in checkout rec = pool._do_get() File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 1138, in _do_get self._dec_overflow() File "/env/lib/python3.5/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File "/env/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 187, in reraise raise value File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 1135, in _do_get return self._create_connection() File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 333, in _create_connection return _ConnectionRecord(self) File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 461, in __init__ self.__connect(first_connect_check=True) File "/env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 651, in __connect connection = pool._invoke_creator(self) File "/env/lib/python3.5/site-packages/sqlalchemy/engine/strategies.py", line 105, in connect return dialect.connect(*cargs, **cparams) File "/env/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 393, in connect return self.dbapi.connect(*cargs, **cparams) File "/env/lib/python3.5/site-packages/pymysql/__init__.py", line 90, in Connect return Connection(*args, **kwargs) File "/env/lib/python3.5/site-packages/pymysql/connections.py", line 699, in __init__ self.connect() File "/env/lib/python3.5/site-packages/pymysql/connections.py", line 959, in connect raise exc pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 2] No such file or directory)")

On Friday, May 5, 2017 at 9:57:43 AM UTC-7, Adam (Cloud Platform Support) wrote:
This is a known issue with the tutorial. The NODE_ENV environment variable doesn't get set to "production" automatically, so the app still tries to connect to localhost in production and fails. A workaround is to add the following to your config.json:

"NODE_ENV": "production"

Note that to actually see the /cloudsql socket, you need to connect to the running docker container after SSHing into the instance eg.

sudo docker exec -it gaeapp /bin/bash
ls
-l /

On Friday, May 5, 2017 at 9:50:49 AM UTC-4, Rei Y. wrote:
I followed https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql. The deployed app fails to connect to the socket, which not seem to be present when I
ssh into the instance in /cloudsql (the directory is empty). App and SQL instance are in the same project.

I have the following in app.yaml:

beta_settings:
  cloud_sql_instances: project:location:instance
 
and in mysql options in nodejs

socketPath: "/cloudsql/project:location:instance"

 Nothing appears in the logs, except in my app stderr

{"code":"ENOENT","errno":"ENOENT","syscall":"connect","address":"project:location:instance","fatal":true}

(project:location:instance is not actually "project:location:instance" but the value for connectionName returned by `gcloud sql instances describe`)

--
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/0eda1899-0970-40fc-a976-eed8ebe2e47c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment