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 simplenotes.io 80
Trying simplenotes.io
Connected to simplenotes.io.
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 simplenotes.io 80
Connection to simplenotes.io 80 port [tcp/http] succeeded!
[[email protected] /]# nc -v -z simplenotes.io 81
nc: connect to simplenotes.io port 81 (tcp) failed: No route to host

Leave a Reply

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