Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`netstat` doesn't show sockets binded by python SimpleHTTPServer?

A local server is run using the SimpleHTTPServer module from Python 2.7

$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

Then I use netstat to search for that socket using 8000 as a filter for port number, however, I can't find any socket with the filter (even when I open a browser window and access 127.0.0.1:8000).

$ netstat | grep 8000
// "return Nothing"

Does anyone have ideas about why I can't see the socket binded by Python SimpleHTTPServer in netstat?

like image 732
Hanfei Sun Avatar asked Mar 06 '26 15:03

Hanfei Sun


1 Answers

Extending the answer by @MK.


By default, netstat shows only the connected ports, but NOT those which just listening idly. Hence, the confusion.
The author of netstat made the call either for simplicity or for aesthetics.

if you make a connection to that :8000 port, it will show up in just netstat call.

Else, you have to make it explicit that you want it ALL.

netstat -a | grep 8000
like image 93
kmonsoor Avatar answered Mar 08 '26 09:03

kmonsoor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!