Luke Oliff.

TIL: Quick Network Debugging With nc (netcat)

·TIL·1 min read·Luke Oliff

netcat is the simplest network tool that exists. It opens a TCP connection from the terminal with no ceremony.

nc -zv api.example.com 443

The -z flag scans without sending data. -v gives verbose output. It tells you whether port 443 is open and accepting connections.

echo "GET /v1/status HTTP/1.1\r\nHost: api.example.com\r\n\r\n" | nc api.example.com 80

Send raw HTTP requests by piping text into nc. Useful for testing APIs without curl or a browser.

nc -l 9999

Starts a listener on port 9999. Anything that connects and sends data appears in your terminal. A quick way to inspect what a client is sending.

Is netcat available on macOS?

Yes. The BSD version is built into macOS. Install the GNU version with brew install netcat for more features.

Is nc secure for production use?

No. nc does not support TLS. Use openssl s_client for SSL/TLS connections.