Skip to content

fix: check 0.0.0.0 when detecting if port is in use#21419

Closed
VedantMadane wants to merge 1 commit into
vitejs:mainfrom
VedantMadane:fix/check-all-interfaces-for-port
Closed

fix: check 0.0.0.0 when detecting if port is in use#21419
VedantMadane wants to merge 1 commit into
vitejs:mainfrom
VedantMadane:fix/check-all-interfaces-for-port

Conversation

@VedantMadane
Copy link
Copy Markdown

Fixes #10638. When another server is on 0.0.0.0:port, Vite would still bind to localhost:port without detecting the conflict, hijacking the port. This fix proactively checks if the port accepts connections on 0.0.0.0 before binding.

Fixes vitejs#10638

When another server is listening on 0.0.0.0:port, Vite would still
try to bind to localhost:port without detecting the conflict. This
caused Vite to 'hijack' the port, responding to requests intended
for the other server.

The fix proactively checks if the port is accepting connections on
0.0.0.0 (and other relevant interfaces) before attempting to bind.
If the port is in use, Vite will try the next available port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check 0.0.0.0 as well as localhost/127.0.0.1 when checking for used port

1 participant