🗄️Database connection failed
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
- Copy the connection address again from the database service's dashboard and put it in the environment variable
- Check that the deployed site's environment variables have the same value
- 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
- Table doesn't exist
relation "…" does not exist - Login address mismatch (redirect_uri_mismatch)
Error 400: redirect_uri_mismatch - Blocked by security rules (RLS), so it won't save
new row violates row-level security policy - Tried to save a value that already exists (duplicate)
duplicate key value violates unique constraint - Login info has expired (JWT)
JWT expired - Login app info is wrong (invalid_client)
Error 401: invalid_client - Google login blocked (app not verified, testing mode)
Access blocked: app has not completed the Google verification process - Prisma isn't ready (prisma generate)
@prisma/client did not initialize yet. Please run "prisma generate"