Monday, May 9, 2022

[google-cloud-sql-discuss] ENOENT connecting to a mySQL instance using node.js

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)

--
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/77a94f8f-1730-4c1b-86e9-8ae1c2ed2f19n%40googlegroups.com.

No comments:

Post a Comment