-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
portfinder yields a port that is already in use #13
Comments
Oh, ah hah! I figured out the difference: ➜ node -e 'require("portfinder").getPort({host: "127.0.0.1"}, console.log)'
null 8001
➜ node -e 'require("portfinder").getPort({host: "0.0.0.0"}, console.log)'
null 8000
➜ node -e 'require("portfinder").getPort(console.log)'
null 8000 Looks like So, I guess for the purposes of this issue... Should portfinder maybe check 127.0.0.1 instead? Or in addition to 0.0.0.0? Or should this really just be a documented gotcha? |
@lmorchard this same issue was actually brought up in #9 It's a feature that should really be documented in the |
Explicitly setting host fixed the issue for me 👍 |
I've seen similar issues, in each case it boied down to the following:
This has a funny property, as depending on several outside conditions some requesters will prefer IPv4 and IPv6 over another. For example, curl against localhost will prefer IPv6, but curl against a host entry, tends to prefer IPv4. This actually masks many failure scenarios, and made debugging initially slightly more tricky. Proposed solution is to (by default) check both IPv6 and IPv4, maybe allowing users to opt into something more specific. This would have the least surprising results. |
I made a go at this let me know thoughts - don't mind cleaning up for style, etc this would unblock ember-cli/ember-cli#5352 feedback much appreciated |
@eriktrom link? |
So, this issue might be related to #9. I'm seeing this on Mac OS X:
In other words, I have port 8000 forwarded to an Android device via
adb
and there's a service running that responds to curl. But, portfinder does not detect it, and it offers 8000 as a free port.This doesn't seem limited to
adb
. Per #9, I tried running a PHP dev server and got similar results:(switch to another shell)
In other words, there's an HTTP server running on port 8000 via
php -S
and it responds to curl. But, portfinder offers up its port as free.But then, for the hell of it, I tried running a SimpleHTTPServer with Python.
This time, portfinder worked as expected:
➜ python -m'SimpleHTTPServer' Serving HTTP on 0.0.0.0 port 8000 ...
(switch to another shell)
So, I guess I'm wondering what are
adb
andphp
doing differently from the Python server that causes portfinder to not detect the occupied port?The text was updated successfully, but these errors were encountered: