Is there a way to check if a certain port is open on server?
Asked Answered
H

5

8

Just as you'd ping an IP of to a server to check if it is up, can we also check if, on that running server, a port is active/open?

this just comes from my head,but can you be more specific in your ping statement?

 `ping 127.0.0.1:7004`

I know this command is not allowed, but is there a way to check for this in Linux and Windows?

Historical answered 4/6, 2015 at 5:3 Comment(0)
C
6

That depends upon your access to system (client or server), You can use either of two options,

  1. Server side you can use netstat -an to check which ports are listening
  2. From outside use just telnet host port, if it is not working on linux machines try telnet host:port.
Cadmar answered 4/6, 2015 at 5:11 Comment(3)
Don't use code formatting for text that isn't code.Aurea
@EJP I selected only relevant code but it took whole line.. Even I didn't like it at first place.. I think either code formatting has issues with bullets or I did something bad. Anyways thanks for formatting it..Cadmar
Thank you, I am on the server side and netstat is doing exactly what I wanted :)Historical
A
9

If you are willing and able to install software, you can use nmap

nmap -p 7004 127.0.0.1

Or if it is internet facing, use a web service such as http://www.yougetsignal.com/tools/open-ports/

Ancelin answered 4/6, 2015 at 5:16 Comment(0)
C
6

That depends upon your access to system (client or server), You can use either of two options,

  1. Server side you can use netstat -an to check which ports are listening
  2. From outside use just telnet host port, if it is not working on linux machines try telnet host:port.
Cadmar answered 4/6, 2015 at 5:11 Comment(3)
Don't use code formatting for text that isn't code.Aurea
@EJP I selected only relevant code but it took whole line.. Even I didn't like it at first place.. I think either code formatting has issues with bullets or I did something bad. Anyways thanks for formatting it..Cadmar
Thank you, I am on the server side and netstat is doing exactly what I wanted :)Historical
W
2

As telnet is disabled by most corporate customers, i found that powershell command on windows machines for TCP quite useful: New-Object System.Net.Sockets.TcpClient("server", port)

Willemstad answered 8/2, 2022 at 15:31 Comment(2)
thank you. Though this one expects me to know the port number... but it is a command I did not know if. ThanksHistorical
Yes you are welcome, that was part of the question with knowing the port and checking whether it is open. If you are on the server side and want to check open ports on windows you can use the "resource monitor" > network tab> listening portsWillemstad
P
0

For TCP-Ports you can simple use telnet or nc to establish a connection. If it succeeds, the port is open.

But as UDP is stateless you cannot check that simple for an open port. You have to know which service is behind this port and know how to send a valid packet so you get an answer.

Ploughman answered 4/6, 2015 at 5:58 Comment(0)
D
0
$ docker run -it --rm --network host networkstatic/nmap localhost
Deft answered 23/6 at 18:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.