47
I cannot connect to my server via SSH. I get "Connection refused" error. The server is running and I can ping it. What could be wrong?
Loading...
Q&A · Answered
I cannot connect to my server via SSH. I get "Connection refused" error. The server is running and I can ping it. What could be wrong?
Accepted answer
The "Connection refused" error typically means SSH service is not running or firewall is blocking. Here's how to fix it:
# Check SSH status
sudo systemctl status sshd
# If not running, start it
sudo systemctl start sshd
sudo systemctl enable sshd
# For UFW (Ubuntu)
sudo ufw allow ssh
sudo ufw status
# For firewalld (CentOS/RHEL)
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
sudo netstat -tlnp | grep ssh
# or
sudo ss -tlnp | grep sshSay what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.