LightAtom

telnet Command: Test a Port (and What to Use on Mac)

Apple removed telnet in macOS High Sierra. nc does the same port tests, and Homebrew can reinstall telnet if you really need it.

nc -vz mail.example.com 25

Test whether port 25 accepts connections (the usual reason people reach for telnet).

beginner5 min

When to use it

People use telnet to test whether a port is open, or to talk to a text protocol by hand (SMTP, HTTP, Redis). On a Mac, nc covers both. Never use telnet to log in to devices: it sends passwords in plain text.

Steps

  1. Test a port

    -v verbose, -z just check, -w timeout.
    nc -vz -w 3 apple.com 443
  2. Talk to a service interactively

    Without -z, nc connects and passes what you type. Here, an SMTP greeting.
    nc mail.example.com 25
  3. Send a raw HTTP request

    Type the request lines, then an empty line.
    printf 'HEAD / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n' | nc example.com 80
  4. If you need telnet itself

    Homebrew provides it.
    brew install telnet

Output explained

Connection to apple.com port 443 [tcp/https] succeeded!
nc: connectx to 127.0.0.1 port 9 (tcp) failed: Connection refused

succeeded means the port accepts connections; Connection refused means nothing listens there; no answer until the timeout usually means a firewall drops the traffic.

Options and variations

FlagMeaningExample
nc -zCheck only, send nothingnc -z host 22
nc -vReport the resultnc -vz host 443
nc -w NTimeout in secondsnc -vz -w 2 host 25
nc -uUDP modenc -u host 53
openssl s_clientLike telnet, for TLS portsopenssl s_client -connect host:443

Common errors

ErrorCauseFix
zsh: command not found: telnetRemoved since macOS 10.13Use nc, or brew install telnet.
nc hangs with no outputFiltered port, no timeout setAdd -w 3.

Do it in the app

To check your own Mac's ports, LightAtom's Ports view lists every listening port and the app behind it.

Frequently asked questions

Why is telnet not on my Mac?

Apple removed telnet in macOS 10.13 High Sierra because it's insecure. Use nc to test ports, or install telnet with Homebrew.

How do I test if a port is open on a Mac?

Run nc -vz host port. “succeeded” means it's open; “refused” means closed; a timeout means filtered.

How do I test a TLS port like 443 or 993?

Use openssl s_client -connect host:993. It handles the TLS handshake so you can talk to the service.

LightAtom team

The people who build LightAtom, a network monitor for macOS.