Using netcat for a Simple Connectivity Test

This is mainly for myself when I forget how to this.

I use netcat, nc, to test connectivity between two hosts from time to time, often with containers in Docker compose, but I don’t do it often enough to remember the syntax.

So here it is.

To start the listener, run this -

nc -l -p 9999

And to connect to the listener, run this -

nc <listener-host> 9999

When the listener is in a container, you can use the container name as the listener-host. Or if the listener and the connecting host are on the same host, you can use localhost as the listener-host.

comments powered by Disqus

Related