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-fpm2. Is It Listening on the Right Port?
# Show all listening ports
ss -tlnp
# Check specific port
ss -tlnp | grep :80
ss -tlnp | grep :33063. 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-onlyFix: 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:804. Is the Firewall Blocking?
# Check iptables
iptables -L -n | grep 80
# Check nftables
nft list ruleset | grep 80
# Check UFW
ufw status5. Is the Port Already in Use?
ss -tlnp | grep :80
# If another process is using the port, the service can't startCommon Fixes
| Scenario | Fix |
|---|---|
| Service not started | sudo systemctl start nginx |
| Wrong bind address | Change to 0.0.0.0 in config |
| Firewall blocking | sudo ufw allow 80/tcp |
| Port conflict | Change port or stop conflicting service |
| Service crashed | Check logs: journalctl -u nginx |