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.

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Sentry image

Make it make sense

Only the context you need to fix your broken code with Sentry.

Start debugging →

👋 Kindness is contagious

Dive into this thoughtful article, cherished within the supportive DEV Community. Coders of every background are encouraged to share and grow our collective expertise.

A genuine "thank you" can brighten someone’s day—drop your appreciation in the comments below!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found value here? A quick thank you to the author makes a big difference.

Okay