How to check if a port is open on Windows, Mac, Linux?

check if a port is open

Hey guys if you want to check the list of open ports then following telnet command will help you to check if a port is open or not. So, let’s see how this works and what you have write on your terminal or command prompt to get the list of available ports!

check if a port is open

Methods or Commands to Check if a Port is Open

Widnows OS

The most common commands are ‘netstat -aon’ and ‘telnet.’ Using both you can check if a port is open or not. So, let’s how to use them.

netstat -aon

Netstat displays protocol statistics and current TCP/IP network connections.

  • -a: Displays all connections and listening ports.
  • -o: Displays the owning process ID associated with each connection.
  • -n: Displays addresses and port numbers in numerical form.

So, when you use this command, it will show a list which will contain protocol, local address, foreign address, state(listening/establish), and PID.

telnet

From outside, just use telnet host port (or telnet host: port on Unix systems) to see if the connection is refused, accepted, or timeouts.

  • Connection refused: It means that nothing is running on that port
  • Accepted: It means that something is running on that port
  • Timeout: It means that a firewall is blocking access

So, when you use the telnet command (like telnet example.com 1720) then it shows you either a cursor or a connection failed message. A cursor on screen means the port is open!

Mac

On mac the process to check if ports are open is quite simple and easy as on this OS you can scan the ports using network utility tool.

  • Search for the network utility tool.
  • Click on the Scan tab.
  • Now enter the IP address and range of ports that you want to scan.
  • Click on the scan button.
  • If any port is open then it will be displayed.

Linux

  • Open the terminal.
  • Now wrtie “telnet + IP address or hostname + port number” (e.g., telnet www.example.com 1723 or telnet 10.17.xxx.xxx 5000) to run the telnet command.
  • Now a message will be displayed. If port is open the message will display like this connected to

So, guys this is how to test if a port is open or not.

You can even take the help of third-party tools or websites like yougetsignal.com to check the status of ports. But we recommend go for the inbuilt features instead of using third party tool!