Check if a port is open from the terminal

Is it the firewall, the service, or me?

SNP 065 #513 Filed cmd network linux

shell
nc -zv db.example.com 3306

-z only scans, -v tells you the result. Add -w 3 for a three-second timeout.

Without netcat, bash can do it on its own:

shell
timeout 3 bash -c '</dev/tcp/db.example.com/3306' && echo open || echo closed

For an HTTP port, curl -I https://example.com gives you the headers, which proves the port and the TLS at once.