A TCP service can accept connections while still returning the wrong health response, greeting, or backend content after a deployment. Netcat gives an operator a small smoke test that sends the first expected bytes and shows the raw reply before the endpoint is handed back to users, monitors, or automation.
A smoke test is stronger than a port-open check because it verifies the service speaks the expected protocol at least once. With OpenBSD Netcat, -w sets a short timeout and -N closes the sending side after the request payload reaches end-of-file, which keeps one-shot services from waiting for more input.
The examples use netcat-openbsd on Ubuntu 26.04 against a loopback HTTP-style health endpoint. Replace the address, port, request, and expected text with the service being checked, avoid sending credentials over plaintext TCP, and use Ncat or OpenSSL when the target requires TLS before application data.
Host: service.example.net Port: 8080 Request: GET /health with Host header Expected text: smoke test ok Timeout: 3 seconds
Use a zero-I/O port test first when the only question is whether the TCP socket accepts connections. A smoke test should send or receive enough bytes to prove the service layer answered. Related: How to test a TCP port with Netcat
$ printf 'GET /health HTTP/1.1\r\nHost: service.example.test\r\nConnection: close\r\n\r\n' | nc -N -w 3 127.0.0.1 9080 HTTP/1.1 200 OK Content-Length: 14 Connection: close smoke test ok
printf sends exact CRLF line endings, -N closes the client sending side after the request ends, and -w 3 prevents the command from waiting indefinitely for a quiet endpoint.
$ echo $? 0
A zero exit status means the nc process completed without a local command error. It does not replace checking the response body or greeting for the expected service text.
Use a protocol-specific client when the smoke test needs redirects, TLS validation, cookies, authentication, or request bodies that are easier to express outside raw TCP. Related: How to debug an HTTP request with Netcat
Related: How to connect to a TLS service with Ncat