Code & computing / QUICK REFERENCE
Ncat (netcat) network diagnostics cheat sheet
Quickly test TCP/UDP connectivity, use loopback listeners, inspect streams and make verified TLS connections with Ncat.
Connect to a permitted test service
- Check installed Ncat version
ncat --versionConfirm the installed executable is Nmap Ncat before relying on its option names. [1][2]
- Show supported options
ncat --helpLocal help reflects the installed build and its enabled features. [1][2]
- Open a loopback TCP session
ncat 127.0.0.1 8080Connect to a TCP service already listening on the local machine. [1][2]
- Print connection details
ncat -v 127.0.0.1 8080Report connection information as the TCP session starts. [1][2]
- Show more diagnostics
ncat -vv 127.0.0.1 8080Repeated verbose flags provide additional diagnostic messages. [1][2]
- Set connection timeout
ncat -w 3 127.0.0.1 8080Stop trying a connection after the specified wait interval. [1][2]
- Test TCP port without sending
ncat -z -w 3 127.0.0.1 8080Zero-I/O mode reports whether a local TCP connection succeeds. [1][2]
- Verbose port check
ncat -z -v -w 3 127.0.0.1 8080A quick local listener check with connection-status details. [1][2]
- Use UDP mode
ncat -u 127.0.0.1 9001Sends datagrams rather than opening a TCP stream; no handshake confirms a listener. [1][2]
Safe loopback listener examples
- Start local TCP listener
ncat -l 127.0.0.1 9000Binds only loopback; a separate local terminal can connect to this port. [1][2]
- Keep local listener available
ncat -lk 127.0.0.1 9000Accepts multiple clients; terminate it when the diagnostic task is complete. [1][2]
- Start verbose listener
ncat -lv 127.0.0.1 9000Displays connection notices while listening on localhost. [1][2]
- IPv4 loopback listener
ncat -4 -l 127.0.0.1 9000Explicitly limits the listening socket to IPv4 loopback. [1][2]
- UDP loopback listener
ncat -u -l 127.0.0.1 9001Receives UDP datagrams addressed to the local test socket. [1][2]
- Keep UDP listener open
ncat -u -lk 127.0.0.1 9001Can continue handling local UDP test traffic until stopped. [1][2]
- Receive only
ncat --recv-only -l 127.0.0.1 9000Prevents keyboard input from being transmitted back to the connected client. [1][2]
- Send only
ncat --send-only -l 127.0.0.1 9000The listener writes outgoing data but ignores anything sent by a client. [1][2]
- Limit allowed client host
ncat -l --allow 127.0.0.1 127.0.0.1 9000Restricts inbound connections to the numeric local IPv4 address. [1][2]
Inspect application streams
- Send local test text
printf 'hello\n' | ncat --send-only 127.0.0.1 9000Sends a line to an already running local TCP listener and exits on input EOF. [1][3]
- Receive a response
ncat --recv-only 127.0.0.1 9000View data from the other endpoint without typing into the session. [1][3]
- Send HTTP request locally
printf 'GET / HTTP/1.0\r\nHost: localhost\r\n\r\n' | ncat 127.0.0.1 8080Interrogate a plain HTTP loopback server using correctly terminated request lines. [1][3]
- Add CRLF automatically
ncat -C 127.0.0.1 8080Converts typed line endings into CRLF for text-based protocols. [1][3]
- Write session log
ncat -o /tmp/ncat-session.log 127.0.0.1 8080Records session data locally; logs can include private messages. [1][3]
- Hexadecimal session dump
ncat -x /tmp/ncat-hex.log 127.0.0.1 8080Preserves hexadecimal data for binary-protocol diagnosis. [1][3]
- Append to an existing log
ncat -o /tmp/ncat-session.log --append-output 127.0.0.1 8080Appends instead of replacing the selected session log. [1][3]
- Use only outgoing data
printf 'probe\n' | ncat --send-only 127.0.0.1 9000Avoid waiting for a reply when verifying basic payload receipt. [1][3]
- Wait briefly after input EOF
printf 'ping\n' | ncat -q 2 127.0.0.1 9000Quit after the configured EOF delay while allowing short response time. [1][3]
- Don't half-close after EOF
ncat --no-shutdown 127.0.0.1 9000Keep send-side socket behavior when stdin reaches EOF; protocol-specific. [1][3]
TLS, controls and interpretation
- Require verified TLS
ncat --ssl-verify test.example 443Authenticate the remote certificate and negotiate encryption; use a real trusted service hostname. [1][4][3]
- Encrypted without verification
ncat --ssl test.example 443This encrypts traffic but does NOT verify the peer; do not treat it as authenticated. [1][4][3]
- Supply a trusted CA bundle
ncat --ssl-verify --ssl-trustfile ca.pem test.example 443Custom PEM trust chain must be appropriate for the expected service. [1][4][3]
- Set a virtual host via SNI
ncat --ssl-verify --ssl-servername test.example test.example 443Send explicit SNI for a TLS virtual host while requiring certificate verification. [1][4][3]
- Verbose certificate check
ncat -v --ssl-verify test.example 443More logging helps diagnose handshake and certificate issues. [1][4][3]
- Try a SOCKS5 proxy
ncat --proxy proxy.example:1080 --proxy-type socks5 test.example 443Use only a permitted proxy and destination; transport is plain unless TLS is separately enabled. [1][4][3]
- Try an HTTP proxy
ncat --proxy proxy.example:3128 --proxy-type http test.example 443TCP connection traverses an explicitly configured HTTP proxy. [1][4][3]
- Combine proxy and TLS
ncat --proxy proxy.example:3128 --proxy-type http --ssl-verify test.example 443Encrypt and authenticate destination TLS after proxy negotiation. [1][4][3]
- Check TCP versus UDP
TCP connects; UDP sends without handshakeA successful UDP send does not prove any application is receiving. [1][4][3]
- Interpret connection refused
Port closed, no listener, or active rejection are possibilitiesCheck local binding, protocol and service status rather than assuming a firewall. [1][4][3]
Reserved placement, separate from reference controls. No ad network is active.
No matching entry. Try a shorter word or clear the search to see the complete sheet.
Sources
cheatsheetatlas.com/sheets/ncat/ · Updated 2026-10-20 · Nmap Ncat · current user guide