SSH Connection Refused — “ssh: connect to host 1.2.3.4 port 22: Connection refused”

Symptoms: You attempt ssh root@ or ssh user@ and get “Connection refused.”

Possible causes & fix steps:

  • SSH daemon isn’t running / failed to start. Check with sudo systemctl status sshd (or ssh) on the server. If stopped — sudo systemctl start sshd.

  • Firewall (cloud-level or server-level) is blocking port 22. For server firewall (ufw/iptables): allow with sudo ufw allow 22 (or your custom SSH port) then sudo ufw reload.

  • Cloud-provider security group or cloud-firewall not allowing inbound SSH. If using VPC / cloud firewall, ensure inbound rule for SSH port from your IP / IP-range is present.

  • SSH configured to run on a non-standard port — ensure you specify correct port (ssh -p PORT …) and firewall rule matches.

Why it matters: Without SSH you lose remote server access — cannot manage server, deploy apps, fix issues. Quick check of port, firewall, and SSH service resolves 90 % of cases.