SSH Not Working? Your Network Might Be Blocking Port 22
If SSH to your server just hangs, the network you’re on (university/corporate/public Wi-Fi) may block outbound port 22.
Diagnose
### Ping works
ping <your-server-ip>
### But SSH hangs / times out
ssh <user>@<your-server-ip>
### Check if port 22 is reachable
nc -zv -w 5 <your-server-ip> 22
If ping works but nc to port 22 times out, your network is blocking SSH.
#3 Fix: run SSH on port 443
Port 443 (HTTPS) is rarely blocked. Add SSH on 443 (keep 22 too).
Ubuntu 22.10+ (systemd socket activation)
On modern Ubuntu, SSH may be managed by ssh.socket, which can ignore sshd_config port lines. Add a systemd drop-in:
sudo mkdir -p /etc/systemd/system/ssh.socket.d
sudo tee /etc/systemd/system/ssh.socket.d/listen.conf <<'EOF'
[Socket]
ListenStream=
ListenStream=22
ListenStream=443
EOF
sudo systemctl daemon-reload
sudo systemctl restart ssh.socket
The empty ListenStream= clears defaults; the next lines add ports.
Verify:
ss -tlnp | grep ssh
You should see listeners on :22 and :443.
Older Ubuntu / other distros (sshd_config)
Edit:
sudo nano /etc/ssh/sshd_config
Add:
Port 22
Port 443
Restart:
sudo systemctl restart ssh
Update your local SSH config
Edit ~/.ssh/config:
Host myserver
HostName <your-server-ip>
User <user>
Port 443
Then connect:
ssh myserver
Why this works
Most networks allow outbound 443 for HTTPS. Running SSH on 443 bypasses port-22 blocks.
Written after spending 20 minutes wondering why SSH wouldn’t work on a locked-down network.
Access server apps without exposing ports (SSH port forwarding)
Once you can SSH in, you can reach any service running on the server without opening it to the public internet.
ssh -L 8501:localhost:8501 hetzner
Then open:
http://localhost:8501
Your laptop SSH tunnel (encrypted) Server
localhost:8501 ---------> over your SSH connection ---------> localhost:8501
(browser) (your app)
This works for Streamlit, Jupyter, databases, internal dashboards—anything listening on localhost on the server. The app stays private, and traffic stays encrypted.
Common examples
# Jupyter Notebook
ssh -L 8888:localhost:8888 hetzner
# PostgreSQL
ssh -L 5432:localhost:5432 hetzner