https://supabase.com/ logo
#javascript
Title
# javascript
m

Mattias

10/20/2021, 12:39 PM
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

silentworks

10/20/2021, 12:42 PM
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

Scott P

10/20/2021, 1:28 PM
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.