Test if a port is open (nc -zv) and find your local IP address
Check whether a remote port is open with nc -zv or Test-NetConnection, and find your computer's local IP address with ip a, ifconfig or ipconfig.
Two small checks solve many connection problems: can this computer reach a port on another machine, and what is this computer's own address. Use nc or Test-NetConnection for the first and ip, ifconfig or ipconfig for the second.
Check a port, then find your address
- Test the port: nc -zv hostname 443 on macOS and Linux, or Test-NetConnection hostname -Port 443 on Windows PowerShell.
- Read the result: a line saying succeeded means the port accepted the connection.
- Find your own address with the command for your system (below).
- Use that address from your phone or another computer, as in open from phone.
Commands you can copy
nc -zv example.com 443nc -zv example.com 20-30nc -zv -w 3 example.com 443Test-NetConnection example.com -Port 443Test-NetConnection example.com -Port 443 -InformationLevel Quietip aip -br -4 addrifconfigipconfigReading the results
- nc -z and -v
- -z checks whether something is listening without sending data. -v prints the result, such as Connection to host 22 port [tcp/ssh] succeeded!. -w sets a timeout in seconds; without it there is none.
- UDP
- nc -uz always reports success whatever the target's state, so it cannot tell you whether a UDP port is open.
- Test-NetConnection
- With -Port it tests TCP and shows TcpTestSucceeded : True or False. Without -Port it pings. -CommonTCPPort accepts SMB, HTTP, RDP and WINRM.
- Succeeded but the app still fails
- The port is open but the app may reject you, or use another protocol. Check the app's log.
- Failed or timed out
- A firewall, a wrong address, or nothing listening. Test from another network to separate your firewall from theirs. For your own machine, see the port checker.
- ip a
- The object name can be abbreviated: ip a is ip address. -br gives a short table, and -4 shows only IPv4. Look for an address like 192.168.1.25 on your Wi-Fi or Ethernet interface.
- 127.0.0.1 is not your network address
- That is the loopback address. Your address for other devices is the 192.168.x.x or 10.x.x.x one.
- Router address
- Your router's address is a different thing; use the router IP finder.
Questions about Test a port and find your IP
- How do I test if a port is open?
- nc -zv host port on macOS and Linux, or Test-NetConnection host -Port port on Windows.
- How do I find my local IP address on Linux?
- Run ip a, or ip -br -4 addr for a short list.
- How do I find my IP on macOS?
- Run ifconfig and look for the inet line on en0 (Wi-Fi), or open System Settings, then Wi-Fi.
- Is telnet still needed?
- Usually not. nc and Test-NetConnection do the same job and are more often installed.