brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: nc -zv tells you whether a TCP port is open

Network and access
~/tips/nc-port

nc -zv example.com 443

Tests whether a TCP port accepts connections, without sending any data.

When something cannot connect, I first want to know if the port answers at all. nc can check that in a second and without a client.

nc -zv example.com 443
nc -zv -w 3 192.168.1.10 22

-z only checks that a connection can be made and sends no data, -v prints the result, and -w 3 gives up after three seconds. It prints succeeded or refused, or just times out when a firewall drops the packets.

Caveat: there are several versions of netcat and they differ in details. The flags above work in the OpenBSD version, which is the one on macOS and on Debian and Ubuntu. Checking UDP ports with -u gives unreliable answers.

Further reading: nc(1)

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link