nc netcat - macOS


nc-netcat is a command-line utility for establishing network connections with various protocols and performing various network operations. It can be used for testing, debugging, monitoring, and data transfer tasks.


nc-netcat [-options] [host] [port]


  • -4, –ipv4: Force IPv4 addresses.
  • -6, –ipv6: Force IPv6 addresses.
  • -a, –address-family: Address family (ipv4/ipv6).
  • -e, –exec: Pass command’s output to another command.
  • -f, –fork: Fork into background after connection.
  • -G, –group: Set group ID of listening socket.
  • -h, –help: Display help and exit.
  • -i, –input: Read input from a file.
  • -k, –keep-open: Keep listening for new connections.
  • -l, –listen: Listen for incoming connections.
  • -n, –numeric: Don’t try to resolve hostnames.
  • -o, –output: Write input to a file.
  • -p, –port: Remote or local port number.
  • -q, –quiet: No output except on error.
  • -r, –random-source: Use a random source for numbers.
  • -s, –source-address: Local address to use.
  • -t, –tcp: Use TCP protocol.
  • -u, –udp: Use UDP protocol.
  • -U, –unix-socket: Socket path.
  • -v, –version: Display version and exit.
  • -w, –wait: Delay between retries in seconds.
  • -x, –proxy: SOCKS5 proxy address.
  • -z, –zero: Send only nulls.


Connect to a remote host on port 80 using TCP:

nc-netcat 80

Listen for incoming connections on port 5000 using TCP:

nc-netcat -l -p 5000

Transfer data between two hosts over UDP:

nc-netcat -u hostname1 1234 | nc-netcat -u hostname2 5678

Command chaining with nc-netcat:

echo "Hello" | nc-netcat -u hostname 1234

Common Issues

  • Connection refused: Ensure that the remote host is accepting connections on the specified port and protocol.
  • Connection timed out: Increase the -w option’s value or check for network connectivity issues.
  • Invalid address: Verify that the hostnames or IP addresses are correct.


  • Piping: Output from nc-netcat can be piped to other commands for processing.
  • Scripts: nc-netcat can be used in scripts for automated network tasks.
  • Chaining: Multiple instances of nc-netcat can be chained to create complex network connections.
  • netstat
  • tcpdump
  • socat
  • telnet