ECONNREFUSED: connection refused: How to Fix It | SheCodes

Can’t connect · Needs a closer look

ECONNREFUSED: connection refused

Your app can’t reach the server or API. The service might be down, or you might be offline.

What the error looks like

Error: connect ECONNREFUSED 127.0.0.1:5432

Why it happens

The API server is down, the URL is wrong, your internet connection dropped, or a firewall is blocking the request.

How to fix it

  1. Check your internet connection
  2. Verify the API URL is correct
  3. If it’s a local server, make sure it’s running
  4. Try again in a few minutes, as the service might be temporarily down

Ask your AI coding tool to fix it

Paste this prompt into Claude Code, Cursor, Bolt or Lovable, with your own error in place of the example.

I'm getting this error and I need help understanding and fixing it:

```
Error: connect ECONNREFUSED 127.0.0.1:5432
```

Please:
1. Explain what this error means in plain English
2. Tell me the most likely cause
3. Give me the exact code changes or commands I need to fix it
4. Show me how to prevent this error in the future

Got a different error?

Paste any error into the free Error Decoder and get it explained in plain English, with a fix prompt.

Decode my error

More common errors explained