Netcat is a super simple but very versatile way to test basic network connectivity. The nc man page says it best:

The nc (or netcat) utility is used for just about anything under the sun involving TCP or UDP. It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning, and deal with both IPv4 and IPv6.

I've written this post as a personal reference to go back to whenever I have a connectivity issue with machines being unable to access each other, or services being unavailable across networks.

Client/server connectivity examples

Server IP: Client IP:

TCP server/client on port 4242

On server

nc -l 4242

On client

nc 4242

Type a line and hit enter in either the client or server window and it will be transmitted and displayed in the opposite window! If it is not displayed, there is a connection issue or an incorrect command.

UDP server/client on port 50642420

On server

nc -u -l 4242

On client

nc -u 4242

TCP client has multiple IPs or interfaces

On server (no change)

nc -l 4242

On client

nc 4242 -s

Other Examples

Scan ports

Scan ports between 4242 and 8484 on

nc -z 4242-8484

Test a web server

This just does a simple HTTP GET.

echo -n "GET / HTTP/1.0\r\n\r\n" | nc 80


That's all for now!