Hi,
I deployed my Node.js project on Vercel, and my database is hosted on Supabase.
I set the environment variables (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME), but my app shows a connection error.
DB_HOST=db.emtyjepwczgxglewnpzs.supabase.co
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=******
DB_NAME=postgres
The app connects fine on my local machine, but on Vercel I get this error:
javascript
Copy code
Error: getaddrinfo ENOTFOUND db.emtyjepwczgxglewnpzs.supabase.co
Could you please explain the correct way to connect a Vercel project to a Supabase database?
Should I adjust the connection string or use a specific Vercel configuration?
Thank you!
The ENOTFOUND error usually means your app can’t find the database host. Basically a DNS issue! Here are a few things to try:
Make sure your connection string is in the right format. You can grab it directly from your Supabase dashboard under Settings → Database. It should look like this:
postgresql://postgres:[YOUR-PASSWORD]@db.emtyjepwczgxglewnpzs.supabase.co:5432/postgres
Or instead of setting separate variables, try using a single DATABASE_URL with the full connection string:
DATABASE_URL=postgresql://postgres:your-password@db.emtyjepwczgxglewnpzs.supabase.co:5432/postgres
It’s cleaner and usually avoids issues with missing or mismatched parts of the string.
Let us know how you get on!