Open metatick opened 4 years ago
I have the same effect here:
> vue-cli-service serve --port 8081
INFO Starting development server...
98% after emitting CopyPlugin
DONE Compiled successfully in 14822ms 5:35:37 PM
App running at:
- Local: http://localhost:8082/app/
- Network: http://192.168.3.34:8082/app/
Ah, the port is not free... Great then an error message would be more helpful
Version
4.1.1
Reproduction link
https://NA-can-be-reproduced-in-all-projects.com
Environment info
Steps to reproduce
Try to run vue-cli-service serve with a specific IP/port where the port is already in use on a different IP, Eg. port 443 is in use on 127.0.0.1, but free on 192.168.0.1.
Attempting to start vue-cli-service serve with 192.168.0.1:443 will result in port 444 (or higher) being bound instead of 443, even though the port was available
What is expected?
The correct IP/port to be bound
What is actually happening?
The next-highest-globally-available port is bound instead.
This problem stems from the host option not being set on portfinder, which causes portfinder to search for a port that is available on all IP addresses instead of the specific IP that vue-cli-service will listen on.
Passing {host: host} to getPortPromise when a valid host is provided would appear to resolve this issue:
https://github.com/vuejs/vue-cli/blob/6c2496418e2d6bb5e9a4f248c2e7a1b7a10d02d3/packages/%40vue/cli-service/lib/commands/serve.js#L106