nc -vz mail.example.com 25Test whether port 25 accepts connections (the usual reason people reach for telnet).
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
Test a port
-v verbose, -z just check, -w timeout.nc -vz -w 3 apple.com 443Talk to a service interactively
Without -z, nc connects and passes what you type. Here, an SMTP greeting.nc mail.example.com 25Send 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 80If 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
| Flag | Meaning | Example |
|---|---|---|
| nc -z | Check only, send nothing | nc -z host 22 |
| nc -v | Report the result | nc -vz host 443 |
| nc -w N | Timeout in seconds | nc -vz -w 2 host 25 |
| nc -u | UDP mode | nc -u host 53 |
| openssl s_client | Like telnet, for TLS ports | openssl s_client -connect host:443 |
Common errors
| Error | Cause | Fix |
|---|---|---|
| zsh: command not found: telnet | Removed since macOS 10.13 | Use nc, or brew install telnet. |
| nc hangs with no output | Filtered port, no timeout set | Add -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.