Docs / Troubleshooting / Fixing "Connection Refused" Errors

Fixing "Connection Refused" Errors

By Admin · Feb 25, 2026 · Updated Apr 24, 2026 · 156 views · 1 min read

What Does It Mean?

"Connection refused" means the server actively rejected the connection. This is different from "connection timed out" (no response at all). It means the server received your request but nothing is listening on that port.

Step-by-Step Diagnosis

1. Is the Service Running?

systemctl status nginx
systemctl status mysql
systemctl status php8.2-fpm

2. Is It Listening on the Right Port?

# Show all listening ports
ss -tlnp

# Check specific port
ss -tlnp | grep :80
ss -tlnp | grep :3306

3. Is It Bound to the Right Address?

# Service listening on 127.0.0.1 only? Won't accept external connections
ss -tlnp | grep :3306
# If you see 127.0.0.1:3306, it's localhost-only

Fix: change the bind address in the service configuration:

# MySQL: /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address = 0.0.0.0

# Nginx: /etc/nginx/sites-available/default
listen 80;  # not listen 127.0.0.1:80

4. Is the Firewall Blocking?

# Check iptables
iptables -L -n | grep 80

# Check nftables
nft list ruleset | grep 80

# Check UFW
ufw status

5. Is the Port Already in Use?

ss -tlnp | grep :80
# If another process is using the port, the service can't start

Common Fixes

ScenarioFix
Service not startedsudo systemctl start nginx
Wrong bind addressChange to 0.0.0.0 in config
Firewall blockingsudo ufw allow 80/tcp
Port conflictChange port or stop conflicting service
Service crashedCheck logs: journalctl -u nginx

Was this article helpful?