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

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay