How to check if a TCP port is open or closed

You can easily test if the port is open or closed on a remote server in Windows or Linux via telnet client:

(This command is same for Linux and Windows machine, as long as you have the telnet client installed in your machine)

[[email protected] /]# telnet 80
Connected to
Escape character is '^]'.

In Linux you may also use netcat command or known as “nc”, you can simply install this by typing the following in CentOS terminal:

yum install nc

To test the port you can type:

[[email protected] /]# nc -v -z 80
Connection to 80 port [tcp/http] succeeded!
[[email protected] /]# nc -v -z 81
nc: connect to port 81 (tcp) failed: No route to host

Leave a Reply

Your email address will not be published. Required fields are marked *