ENOENT connecting to a mySQL instance using node.js

627 views
Skip to first unread message

Giovanni Minchio

unread,
May 9, 2022, 4:56:28 PM5/9/22
to Google Cloud SQL discuss
Hi
Im having trouble connecting via service (which is running in cloud run) to my db instance (mysql). I search almost everywhere online but none of the provided solutions worked for me. 
The error happend when i try to query the db , here a code snippet:

ABOUT THE POOL INSTANCE
const pool = mysql.createPool({
 user:'username',
 password:'password',
 database:'dbname',
 socketpath:'the instance name given by the instance info page',
});

HOW IM TRYING TO QUERY IT
app.get("/:ATT", async (req, res)=>{
 const query = "SELECT * FROM tabelnameWHERE attribute=?";
 pool.query(query, [req.params.ATT], (error, results)=>{
      if(error){
             res.json(ERROR);
      } else{
             res.json({status:"done !"});
     });
 });

the ERROR returned me the following:
{"errno":-2,"code":"ENOENT","syscall":"connect","address":"/cloudsql/ the instance name given by the instance info page  ","fatal":true}

the instance name im using im sure 100% is the right one

Anyone can help?
I can't get out of it
Thanks in advance. 

PS: i already tried to use the same region for all the projects part but nothing has changed
i tried also to add at the end of the instance name "s.PGSQL.5432", which shuold be completly useless, since is for postresql  i assume (but i was completly lost so i gave it a try anyway)

fiescocasasola

unread,
May 11, 2022, 2:41:06 PM5/11/22
to Google Cloud SQL discuss
Did you use any documentation to come up with the code? If so, could you please post the documentation you used? Could you also provide more information to be able to reproduce your project? 
Reply all
Reply to author
Forward
0 new messages