Ffile2fix
Sign in Get started

How to fix "ERR_CONNECTION_REFUSED"

This site can't be reached
example.com refused to connect.
ERR_CONNECTION_REFUSED

This error means the computer at that address answered, but no program was listening on the port you tried. Usually the web server or app is not running, or it is listening on a different port or address.

Also appears as: localhost refused to connect. · curl: (7) Failed to connect to example.com port 443 after 12 ms: Connection refused · Unable to connect. Firefox can't establish a connection to the server at example.com. · connect ECONNREFUSED 127.0.0.1:3000

Common causes

  • Nginx, Apache or the Node/dev server is stopped or failed to start
  • The app listens on a different port, or only on 127.0.0.1 instead of 0.0.0.0
  • No HTTPS listener on port 443 while the browser forces HTTPS
  • A firewall actively rejects the port (ufw, firewalld, cloud security group)
  • DNS points the domain at the wrong server IP
  • A local proxy or VPN setting in the browser

How to fix it

  1. Check the service is running. Run sudo systemctl status nginx (or apache2). If it failed, run sudo nginx -t to find config errors, fix them, then start it with sudo systemctl start nginx.
  2. See what is listening. Run sudo ss -tlnp | grep -E ':80|:443'. If nothing is on 443, HTTPS is not configured; if the app shows 127.0.0.1:3000, it only accepts local connections.
  3. Open the firewall. Allow web traffic with sudo ufw allow 'Nginx Full' or sudo firewall-cmd --permanent --add-service=https && sudo firewall-cmd --reload. On cloud servers also check the security group.
  4. Verify DNS. Run dig +short example.com and compare it to your server's IP. Update the A record if it points somewhere else.
  5. Fix local dev servers. For localhost errors, start the dev server again and use the exact port it prints. In Docker, publish the port with -p 3000:3000 and bind the app to 0.0.0.0.
  6. Rule out browser proxy settings. Try another browser or curl -v http://example.com. If curl works, check the browser's proxy or VPN extension.

Check listeners and the web server status

sudo ss -tlnp | grep -E ':(80|443)\b'
sudo systemctl status nginx --no-pager
sudo nginx -t && sudo systemctl restart nginx

How to stop it happening again

  • Enable web services at boot with systemctl enable
  • Test config before restarting services
  • Monitor uptime from an outside location
  • Document which ports each app uses

Frequently asked questions

What is the difference between refused and timed out?

Refused means the server replied that nothing is listening, so it fails instantly. A timeout means packets got no reply, which usually points to a firewall dropping traffic or a down server.

Why does localhost refuse to connect?

Your local server is not running or uses another port. Start it and use the port it prints, such as http://localhost:5173.

Can the site be up for others but refused for me?

Yes. Your IP may be blocked by a firewall or fail2ban, or your network may block the port. Test from another network to check.