How to check if ports are open on VPS?

If you are not sure if a certain port is open, you can always check it as explained below.

1.On Windows

method 1: use command line

a)  Right-click on the start menu -> Select Command Prompt (Admin).

b) Type this command to check then hit enter :

netsh firewall show state

Or

netstat -a -n

Output:

As the output below shows your VPS is not blocked any port, you can open any port you want in firewall: How to open a port in Windows Server Firewall

As VPS we are using for you write this you can see I have 3 ports open :443, 3650,161

method 2 : By Using Apps

There are many websites that check port status. Here I am using website: https://portchecker.co/  for test

a) Go to the website.

b) Enter your IP address or click on use current IP.

c) Enter a Port number or select from the drop-down menu on the right side.

d) Click Check.

You will see which ports are open and which ones are closed.

2. On Linux

method 1:

a) Launch Linux terminal application.

b) Type command:

netstat -tulpn | grep LISTEN

or

ss -tulpn

or

lsof -i -P -n | grep LISTEN

Any of these three commands can tell you which ports are open.

method 2: Use telnet

a)Open Terminal on your Linux

b) Install Telnet on linux

For Centos : yum install telnet

For Ubuntu/Debian:  apt-get install telnet

c) Enter “telnet + your IP address  + port number” (e.g: telnet 45.92.x.x 3650) to run the telnet command and test the port status.

d)If the port is open, a message will say Connected to 45.92.x.x

If the port is closed, a message will say Connection refused.

3. On Mac

a) Click the Spotlight icon  in the upper-right hand corner or press Command + Space bar

b) Type “Terminal” in the search field and select Terminal.

c) Enter “nc -zv + your  IP address + port number” (e.g: nc -zv 203.24.x.x 4000 ) to run the telnet command and test the port status.

d) If the port is open, a message will say Connection to 203.24.x.x port 4000 [udp/https] succeeded!

If the port is closed, a message will say nc: connectx to 203.24.x.x port 4000 (tcp) failed: Connection refused.

4.Conclusion

Usually, you don’t have to worry about ports, your Operating System, network hardware, and application manage them. However, it is always a good idea to keep tools handy in case anything goes wrong and you need to figure out what is causing the issue.

Opening or closing the ports or finding if a port is open or not is not a difficult task. You just have to know the right keys to push.