Hi <@!336983535074279444> <@!845250139706753044> o...
# javascript
m
Hi @User @User or any other using the node-postgres library
pg
! Would you mind sharing an example of a connection with Supabase. I keep getting
Error: getaddrinfo ENOTFOUND https://lotsofletters.supabase.co
My code:
Copy code
js
const pool = new Pool({
  user: 'postgres',
  host: import.meta.env.VITE_SUPABASE_URL,
  database: 'postgres',
  password: import.meta.env.VITE_SUPABASE_ANON_KEY,
  port: 5432,
});

pool.query('SELECT NOW()', (err, res) => {
  console.log(err, res)
  pool.end()
})
s
That's not correct, you need to use the information from settings/database
You are trying to connect with your SUPABASE info, that's not correct, those are purely for the client libraries
Host will look something like:
db.[projectId].supabase.co
Password is what you used when you first setup your Supabase project, that was one of the things it asked for
s
Sorry, only just seen this, but the above is correct. The
[id].supabase.co
endpoint you'd use with the JS library routes to several different services, and none of them are a direct connection to the database, and none of them run on port 5432.