🛠️ Real incident, fixed with AI

SSH Timed Out but Ping Worked: UFW Default Policy Was DROP

A Linux box answered ping but SSH from the LAN timed out because UFW's default incoming policy was deny, with no rule for port 22. That policy drops packets.

Problem/symptom

A newly set-up Linux desktop answered ping, but SSH from another LAN device just hung:

ping 192.0.2.19            # replies
nc -zv 192.0.2.19 22       # times out

Environment

Cause

UFW was active with a default incoming policy of deny, and nothing allowed port 22. That policy drops packets, so the connection hangs instead of refusing. The default rules still accept ICMP echo, which made the host look healthy. The SSH service itself was listening fine.

Fix step by step

  1. On the affected machine, check the rules: sudo ufw status verbose. Look for Default: deny (incoming). You will not see the word DROP.
  2. Allow SSH: sudo ufw allow ssh. To limit it to the LAN instead, use sudo ufw allow from 192.0.2.0/24 to any port 22 proto tcp.
  3. Re-test from the other device: nc -zv 192.0.2.19 22.

Lesson/takeaway

A timeout (not “connection refused”) on one port while ping works usually means a firewall is dropping packets. Check the host firewall before touching the SSH daemon.

Spot something wrong or outdated? Leave a comment below. Every comment is reviewed to keep these posts accurate.

By commenting, you agree to our Terms of use and confirm this is your own work. Short quotes are fine with a credit and link. Copied, unsafe, or abusive comments are removed. See something copied? Say so here.