SSH connection refused - how to troubleshoot
Answered
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?
Y
Asked by
youssef_net
Platinum
•
311 rep
1 Answer
16
The "Connection refused" error typically means SSH service is not running or firewall is blocking. Here's how to fix it:
Step 1: Check if SSH service is running
# Check SSH status
sudo systemctl status sshd
# If not running, start it
sudo systemctl start sshd
sudo systemctl enable sshd
Step 2: Check firewall settings
# 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
Step 3: Verify SSH is listening on correct port
sudo netstat -tlnp | grep ssh
# or
sudo ss -tlnp | grep ssh
O
Platinum
•
593 rep
Your Answer
You need to be logged in to answer questions.
Log In to Answer