http-party / node-portfinder

A simple tool to find an open port or domain socket on the current machine
https://github.com/http-party/node-portfinder
Other
882 stars 95 forks source link

All ports lower than 1024 are closed #106

Closed murilobd closed 4 years ago

murilobd commented 4 years ago

I'm trying to inspect if port 123 (NTP Server) is available but I only get as response 1024 (that's the next available port) or if I use stopPort (and startPort) I receive an error: 'No open ports found in between XX and YY'.

I have tested some ports lower than 1024 and all of them either returns 1024 or an error. Any idea why or a possible solution?

image
eriktrom commented 4 years ago

To open a port in the protected range of ports (<= 1024) you need to need the right permissions. That may vary per system. I would try to use a host that will bind to a non loopback interface, for example: { host: 0.0.0.0, port: 80 }. This may require updating your firewall, to allow traffic through that interface (e.g, en0). On mac, u can check that nodjs is listed in system preferences -> security -> firewall. An alert box on mac will show up when you run port finder on a privileged interface for any port. On linux you would need to add the port to your firewall (a simple google query should explain how, depending on the distro). On windows, I'm not sure.

You may need to use sudo, but that is not ideal.

You can cross check these same steps by starting simple http server provided by python, on a privileged interface. The flow should be the same. (aka, start python server on 0.0.0.0 on any port - if there is a difference between how you get a server running with that tool and port finder, security wise, let me know, i'd be curious to hear about it.)

eriktrom commented 4 years ago

closing to cleanup issue list, comments or questions still welcome, if needed