-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Allow running two apps on 127.0.0.1 and another address on same port #12417
Comments
Hi , I tried to reproduce this issue
you get an error , Steps to reproduce
I have looked into the detect-port-alt code. and found that regardless of the host it always check that port against localhost. here https://github.com/Timer/detect-port/blob/master/lib/detect-port.js based on above reasoning lets try to explain the behavior hope this helps |
The upstream has gotten support for hostname, it only has a slightly different interface. Replacing the fork(detect-port-alt) with the upstream(detect-port) one might solves this. It checks if the port is free for the given hostname and port combination if caller provides hostname instead of checking all localhost, default host, ip combinations. Which I believe is what the call for detect is trying to do in So aside from replacing the dependency, the invocation of detect needs to change from: function choosePort(host, defaultPort) {
return detect(defaultPort, host).then( function choosePort(host, defaultPort) {
return detect({port: defaultPort, hostname: host}).then( |
Hi , @Exagone313 Meanwhile until this gets fixed you can use this workaround. let me know if there is any issue? for a proper fix we may have to port the changes from HTH, |
@krreet, unfortunately my usage requires first starting the app on @rv2673 you might want to do that PR yourself, but I can do it in your place if you want (with co-authored-with). (I prefer not to sign the CLA) Or #11424 needs to be taken over. |
@krreet That might require some git history checking over why and when the fork was added(though might be tricky from the quick git blame click through I did on my phone, since there are several refactors and code moves in there). The host functionality was added after 1,5 year after it was added to the fork, around the same time the fork stopped getting updates. (So backporting it might be rather difficult). @Exagone313 or somebody else, feel free to create PR. I messed up my personal desktop last weekend and haven't got it working again yet, and I can't do it from my work computer. |
Looks like CRA was using the original detect-port earlier and was replaced by a "temporary" fork because of the related issue : #2112 @Exagone313 , maybe you can try editing your hosts file meanwhile if it helps as it seems that replacing the forked detect-port might cause regression issues so this one may not be quick to fix. |
Describe the bug
Currently, when starting two React apps with e.g.
HOST=127.0.0.1 PORT=3000
andHOST=127.2.2.2 PORT=3000
, the second app will fail with an errorSomething is already running on port 3000
, although starting two apps on same port but different addresses is valid. Note that this works when not using address127.0.0.1
.Did you try recovering your dependencies?
N/A
Environment
N/A
Steps to reproduce
HOST=127.0.0.1 PORT=3000 npm run start
in a first terminalHOST=127.2.2.2 PORT=3000 npm run start
in a second terminalExpected behavior
Both apps are running on their respective address.
Actual behavior
Only the first app (on
127.0.0.1:3000
) is running, the second app didn't start with an error:Something is already running on port 3000
.When patching the code manually to bypass this check, both apps can run aside without issues.
Reproducible demo
Any React app is applicable.
Trivia
The issue is coming from the package detect-port-alt from @Timer, a fork of detect-port which adds
host
support, but doesn't cover this edge case. Unfortunately, this fork doesn't allow creating GitHub issues and changes have not been upstreamed.The text was updated successfully, but these errors were encountered: