What Is ERR_CONNECTION_REFUSED (Connection Refused) and How Do You Fix It?

Sunucun 5 min read

ERR_CONNECTION_REFUSED is an error showing that your browser reached a server but the server refused the connection request. Chrome then shows “… refused to connect” on the “This site can’t be reached” page together with the code ERR_CONNECTION_REFUSED. The same situation appears as a “Connection refused” message in command-line tools, SSH, database connections and apps. In this guide we explain what the error means, what causes it and how to fix it as a visitor, a developer and a server administrator.

Illustration: What Is ERR_CONNECTION_…

What Does Connection Refused Mean?

When a connection is made, the client sends a connection request to a specific port on the server (such as 80 or 443 for the web, or 22 for SSH). If no service is running on that port to accept the request, or a security rule is set to reject it, the server immediately answers “no” with an RST packet. When the browser receives this answer, it shows ERR_CONNECTION_REFUSED.

This error shows that the server is reachable but does not accept you on that port. If no answer comes at all, the error is ERR_CONNECTION_TIMED_OUT; if the connection is cut after it has been established, you see ERR_CONNECTION_RESET.

Causes of the ERR_CONNECTION_REFUSED Error

  • The service is not running: The web server (Apache, Nginx, LiteSpeed), application server or database may have stopped or crashed.
  • Wrong port: The service runs on a different port from the one you are trying to connect to.
  • The service listens only on the local address: If the application is bound to 127.0.0.1, it can only be reached from the server itself; requests from outside are refused.
  • Firewall rejection: A “reject” rule on the server or network firewall refuses the connection.
  • Wrong IP address or old DNS record: The domain may point to a server that no longer hosts the site.
  • Proxy or security software on the client side: A local proxy that is not working (for example a proxy setting on 127.0.0.1) makes every connection be refused.

How to Fix ERR_CONNECTION_REFUSED as a Visitor

  1. Try the site from another network: Open it on your phone over mobile data. If it does not open there either, the problem is on the site; try again later or let the site owner know.
  2. Check the address: If the address contains a port number such as :8080, make sure it is correct; try both http:// and https://.
  3. Turn off proxy settings: On Windows, if a manual proxy is set under Settings > Network & Internet > Proxy, turn it off. A proxy that is not working causes this error on every site.
  4. Clear the cache and the DNS cache: Clear browsing data and run ipconfig /flushdns in Command Prompt.
  5. Test VPN and security software: Temporarily turn off the VPN and the antivirus web protection and try again.

ERR_CONNECTION_REFUSED on localhost

The case developers see most often is this error on an address such as http://localhost:3000. It means no application on your computer is listening on that port. We explain the concept in our article what is localhost. Things to check:

  • Is the development server (npm, PHP, Python, XAMPP, WAMP and so on) actually running, or did it exit with an error in the terminal?
  • Which port does the application use? The port in the terminal output and the port in the browser must be the same.
  • The port may be in use by another program. Check with netstat -ano | findstr :3000 on Windows, or lsof -i :3000 on Linux and macOS.
  • If you use Docker, make sure you published the container port to your computer (for example -p 3000:3000) and that the application listens on 0.0.0.0 inside the container.
  • Try 127.0.0.1 instead of localhost; on some systems localhost resolves to the IPv6 address (::1), and if the application listens only on IPv4 the connection is refused.

How to Fix Connection Refused as a Server Administrator

1. Check That the Service Is Running

systemctl status nginx
systemctl status apache2     # CentOS/AlmaLinux: httpd
systemctl restart nginx

If the service is not running, restart it and check the logs with journalctl -u nginx --since "1 hour ago" to see why it stopped. If there is a configuration error, nginx -t or apachectl configtest shows the problem.

2. See Which Address and Port the Service Listens On

ss -tlnp

Make sure the port in question is listed and that the address is 0.0.0.0 (or the server’s public IP). A line such as 127.0.0.1:3306 shows that the service accepts only local connections; if outside access is needed, change the bind address in the service’s configuration.

3. Check the Firewall Rules

ufw status                  # Ubuntu/Debian
firewall-cmd --list-all     # CentOS/AlmaLinux
iptables -L -n

If the required port is not open, allow it (for example ufw allow 443/tcp). If your cloud or virtualization panel has a separate security group or network firewall, check that as well.

4. Verify the DNS Record

Check with nslookup yourdomain.com that the domain’s A record points to the right server. Records still pointing to the old server after a migration send visitors to a machine that no longer serves the site.

“Connection Refused” in SSH

The message ssh: connect to host … port 22: Connection refused shows that the SSH service is not running, is listening on a different port, or that the firewall rejects port 22. Connect to the server through console (VNC) access and check the service with systemctl status sshd; if the port was changed, connect with ssh -p 2222 user@ip.

“Connection Refused” with Databases

If your application gets this error when connecting to MySQL, PostgreSQL or Redis, the database service may have stopped, the wrong port or host name may be in use, or the database may accept only local connections. If the application and the database are on the same server, use localhost or 127.0.0.1 in the connection settings; if they are on different servers, check the database’s bind address and make sure the firewall allows only the application server’s IP.

With a VDS server that gives you root access, you can manage the services, ports and firewall yourself and apply all of these steps directly.

Conclusion

ERR_CONNECTION_REFUSED shows that the server was reached but no service accepts requests on the port you want to connect to, or a rule rejects the request. As a visitor, check your proxy settings and try from a different network. As a developer or server administrator, verify that the service is running, that it listens on the right address and port, and that the firewall allows that port.

Categories

Latest guides