A TCP handoff can fail after the port opens if the client sends the wrong first bytes or waits for a service that expects input first. Netcat can open a raw TCP client connection so an operator can send a small protocol line and read the service response without a browser, SSH client, or application wrapper changing the exchange.
The basic client form is nc host port. Use it interactively when the request needs to be typed by hand, or pipe a short payload into nc when the same request should be repeatable. With OpenBSD Netcat, -N closes the network socket after standard input reaches end-of-file, which matters for services that wait for the client side to finish sending before they answer or close.
The examples use OpenBSD Netcat on Ubuntu 26.04 and a loopback test service on 127.0.0.1:9000. Replace the address, port, and payload with the target service, keep secrets out of plaintext TCP, and use Ncat or another TLS-capable client when the service expects TLS before application data.
Related: How to test a TCP port with Netcat
Related: How to grab a service banner with Netcat
Related: How to debug an HTTP request with Netcat
Related: How to connect to a TLS service with Ncat
Tool: Netcat Command Generator
Use a port test first when the only question is whether the socket accepts TCP connections. Use a client exchange when bytes after the connection matter.
Related: How to test a TCP port with Netcat
$ printf 'tcp service says hello\n' | nc -l 127.0.0.1 9000 status
Leave this terminal open before running the client. The status line appears only after the client in the next step connects and sends that payload.
Skip this step when a real test service is already listening.
$ printf 'status\n' | nc -N 127.0.0.1 9000 tcp service says hello
-N is OpenBSD Netcat syntax for shutting down the network socket after stdin reaches EOF. If the installed nc rejects -N, use an interactive client and press Ctrl-D after typing the request, or use the equivalent close-after-EOF option for that Netcat variant.
$ nc service.example.net 12345
Type the request lines exactly as the service expects, then press Ctrl-D when the client must close its sending side.
Netcat does not add protocol headers, authentication, encryption, or retries; every byte typed or piped is what the service receives.
$ nc -v -w 1 127.0.0.1 9001 nc: connect to 127.0.0.1 port 9001 (tcp) failed: Connection refused
Connection refused means the host was reached but that port had no listener. A timeout usually points to an unanswered route, firewall, address, or service-binding issue. A blank successful connection can mean the service is waiting for client input.