How to check open ports in Linux using nc, telnet and curl command ?

Today in this post, we will see how to check for open port in Linux using telnet and curl commands.


I. Using Telnet command
Telnet command is very common, and mostly used to quickly check if a port is open or not on a server.

The syntax is also simple, just mention server-name and then port number separated by a space.

[root@ngelinux-prd ~]# telnet ngelinux-pxy 9000
Connected to ngelinux-pxy.
Escape character is '^]'.
telnet> quit
Connection closed.
[root@ngelinux-prd ~]# 


II. Using Curl command
People are less aware of curl command.
However this is useful many of the times when telnet is not available on the server.

To check 9000 port status on the host ngelinux-pxy.

[root@ngelinux-prd ~]# curl -v ngelinux-pxy:9000
* About to connect() to ngelinux-pxy port 9000 (#0)
*   Trying
* Connected to ngelinux-pxy ( port 9000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: ngelinux-pxy:9000
> Accept: */*

* Connection #0 to host ngelinux-pxy left intact

### Similarly lets check 443 port.
[root@ngelinux-prd ~]# curl -v ngelinux-pxy:443
* About to connect() to ngelinux-pxy port 443 (#0)
*   Trying
* Connection refused
* Failed connect to ngelinux-pxy:443; Connection refused
* Closing connection 0
curl: (7) Failed connect to ngelinux-pxy:443; Connection refused
[root@ngelinux-prd ~]#

Similar to these we have nc command also to check the port open in linux.

Lets check this command also.


III. Using nc command

### Checking 9000 port
[root@ngelinux-prd ~]# nc -zv ngelinux-pxy 9000
Ncat: Version 7.50 ( )
Ncat: Connected to
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.

### As we can see above 9000 port is listening,
### Lets check 900 port
[root@ngelinux-prd ~]# nc -zv ngelinux-pxy 900
Ncat: Version 7.50 ( )
Ncat: Connection refused.
[root@ngelinux-prd ~]#

Here the connection is refused on 900 port which means this is not open, and only 9000 port is open or listening on the server.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments