VibeDict

🗄️Database connection failed

What you'll see
Error: connect ECONNREFUSED 127.0.0.1:5432

The code couldn't connect to the database. The address (DB URL) is wrong, the database is off, or there are too many connections.

🤔 Why does it happen?

  • The database address, like DATABASE_URL, is missing or wrong (127.0.0.1 means "my own computer," so it won't work on the deployed site)
  • A free database went to sleep because it wasn't used for a while
  • Too many connections were opened in a serverless environment

🔧 Try this

  1. Copy the connection address again from the database service's dashboard and put it in the environment variable
  2. Check that the deployed site's environment variables have the same value
  3. If you're on serverless, use the "pooled" connection address the service recommends

🤖 Ask your AI like this

I get the error below when connecting to the database. I'm using [Neon/Supabase/etc.] for the database. Please check the connection address settings and the code, and fix it so it connects reliably on the deployed (serverless) site too. Don't ask me for the password. [Paste the full error here]

Replace the [ ] parts with your own situation, and paste the error with a few extra lines before and after it.

Related terms

Other errors in this group