DEV Community

Cover image for How to check which port are open for connection on remote server
özkan pakdil
özkan pakdil

Posted on • Originally published at ozkanpakdil.github.io on

How to check which port are open for connection on remote server

Today I needed to check which ports are open on a remote server to ensure that the services I need are running and accessible. Here are a few ways to check which ports are open on a remote server:

Telnet

Telnet is a command-line tool that can be used to check if a port is open on a remote server. You can use the following command to check if a port is open:

telnet <hostname> <port>

Enter fullscreen mode Exit fullscreen mode

For example, to check if port 80 is open on example.com, you can run:

telnet example.com 80

Enter fullscreen mode Exit fullscreen mode

Powershell

If you are using Windows, you can use PowerShell to check if a port is open on a remote server. You can use the following command to check if a port is open:

Test-NetConnection -ComputerName <hostname> -Port <port>

Enter fullscreen mode Exit fullscreen mode

Curl

You can also use curl to check if a port is open on a remote server. You can use the following command to check if a port is open:

curl -v <hostname>:<port>

Enter fullscreen mode Exit fullscreen mode

For example, to check if port 22 is open on example.com, you can run:

curl -v -s -m 2 telnet://127.0.0.1:22 </dev/null

Enter fullscreen mode Exit fullscreen mode

wget

You can use wget to check if a port is open on a remote server. You can use the following command to check if a port is open:

wget -O /dev/null http://<hostname>:<port>

Enter fullscreen mode Exit fullscreen mode

nc

You can use nc (netcat) to check if a port is open on a remote server. You can use the following command to check if a port is open:

nc -zv <hostname> <port>

Enter fullscreen mode Exit fullscreen mode

my personal favorite is using nc or curl as it is simple and easy to use. And telnet can not be found on some systems. needs extra installation but curl is mostly available on all systems.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)