Make `vite preview` error-tolerant when the default port is in use
See original GitHub issueClear and concise description of the problem
It is said that the new AirPlay feature in macOS Monterey is using port 5000 and port 7000. https://developer.apple.com/forums/thread/682332.
In the current implementation, vite preview
will straightly fail when port 5000 is in use. So it will fail by default in the new system.
Suggested solution
I don’t know if the default port of this new AirPlay feature will be changed in the future, as it’s not documented yet (in https://support.apple.com/en-us/HT202944).
So I’m not proposing a change to the default port of vite preview
.
But it should be error-tolerant. It should use the next available port when port 5000 is in use. It should still fail when the user specifies an unavailable port.
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Preview Options - Vite
Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not...
Read more >vite preview - the preconfigured localhost:5000 responds with ...
When you change the port like vite preview --port 5001. Then it works. I checked everything. I don't have anything running on port...
Read more >How to configure the CORS on the Vite server to remove the ...
You have to config the other side (the server which serves the image) to resolve it. or use a proxy server to add...
Read more >List of TCP and UDP port numbers - Wikipedia
Port TCP UDP
1024 Reserved Reserved
1025 Yes Yes
1027 Reserved
Read more >Quickstart: Deploy a Node.js service to Cloud Run
Note: If you installed the gcloud CLI previously, make sure you have the latest version by running gcloud components update . To set...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great, I will submit a PR as soon as possible.
Coincidentally, I have a background service that also uses port
5050
. If the port is occupied, it will automatically+1
, which I think is very good. I am willing to contribute this feature.