Localhost:5173 Development Vite Port
# 定义
Port 5173 was chosen by the Vite team as the default development server port. The number 5173 spells 'site' on a phone keypad (5=S, 1=I, 7=T, 3=E), making it memorable and thematically appropriate for a web development tool. Vite has revolutionized frontend development with its extremely fast cold start times and efficient hot module replacement, making port 5173 increasingly common in modern web development workflows.
# Services and Software That Use Port 5173
## Build Tools
## Frontend Frameworks
## Development Tools
## Other Tools
# Frequently Asked Questions
Q: How do I access localhost:5173?
Run 'npm run dev' in your Vite project directory, then open http://localhost:5173 in your browser. Vite will also display the exact URL in the terminal.
Q: Why does Vite use port 5173?
Port 5173 spells 'SITE' on a phone keypad (5=S, 1=I, 7=T, 3=E), making it memorable and appropriate for a web development tool. It's also uncommon enough to avoid conflicts.
Q: How is Vite different from webpack dev server?
Vite uses native ES modules and esbuild for much faster cold starts and hot module replacement compared to webpack. It only bundles code for production, keeping development fast.
Q: How to change Vite port from 5173?
Use 'npm run dev -- --port 8080' for one-time change, or add 'server: { port: 8080 }' to your vite.config.js for permanent configuration.
Q: Should I use port 5173 in production?
No, port 5173 is only for development. In production, build your app with 'npm run build' and serve the dist folder through a proper web server on standard ports.
Q: How to access Vite dev server from other devices?
Use 'npm run dev -- --host' or 'npm run dev -- --host 0.0.0.0' to allow network access, then use your computer's IP address with port 5173.
Q: Why is Vite HMR not working on localhost:5173?
HMR uses WebSocket connections. Check if firewalls are blocking it, ensure correct URL access, and verify that you're not behind a proxy that blocks WebSockets.
Q: How to preview production build on localhost:5173?
Run 'npm run build' then 'npm run preview'. By default, preview runs on port 4173, but you can configure it to use 5173 in vite.config.js preview settings.
# How to Use Port 5173
Create Vite Project
Create a new Vite project using npm, yarn, or pnpm. Choose your preferred framework template (React, Vue, Svelte, etc.).
npm create vite@latest my-app
Navigate and Install Dependencies
Navigate to the project directory and install all required dependencies.
cd my-app && npm install
Start Vite Development Server
Start the Vite development server. It will automatically run on port 5173 with hot module replacement enabled.
npm run dev
Access Your Application
Open your browser and navigate to http://localhost:5173. Vite will display the local and network URLs in the terminal.
curl http://localhost:5173
Enjoy Fast Development
Experience instant server start and lightning-fast hot module replacement. Edit your source files and see changes reflected immediately.
# Common Problems
## MEDIUM Severity Issues
Another Vite instance or service is using port 5173. Vite will automatically try the next available port (5174, 5175, etc.) but this can be confusing.
Vite cannot resolve certain modules or imports, often due to incorrect file paths or missing dependencies.
Changes to source files are not automatically reflected in the browser, defeating Vite's main advantage.
## HIGH Severity Issues
The 'vite' command is not recognized, indicating Vite is not installed globally or the project dependencies are not installed.
## LOW Severity Issues
Code works in development (port 5173) but fails in production build, often due to environment differences or dynamic imports.
# Troubleshooting Solutions
## All Platform
Resolve Vite Port Conflict
For: Port 5173 Already in UseSteps:
- Check if another Vite development server is running
- Kill existing Vite processes if not needed
- Specify a custom port for your Vite server
- Configure permanent port in vite.config.js
npm run dev -- --port 5174
Fix Vite HMR Issues
For: Hot Module Replacement Not WorkingSteps:
- Ensure you're accessing the correct localhost URL
- Check if firewall or antivirus is blocking WebSocket connections
- Verify file watching is working correctly
- Clear browser cache and restart Vite server
npm run dev -- --host 0.0.0.0
Fix Vite HMR Issues
For: Hot Module Replacement Not WorkingSteps:
- Ensure you're accessing the correct localhost URL
- Check if firewall or antivirus is blocking WebSocket connections
- Verify file watching is working correctly
- Clear browser cache and restart Vite server
rm -rf node_modules/.vite && npm run dev
## Linux/macOS Platform
Resolve Vite Port Conflict
For: Port 5173 Already in UseSteps:
- Check if another Vite development server is running
- Kill existing Vite processes if not needed
- Specify a custom port for your Vite server
- Configure permanent port in vite.config.js
lsof -ti:5173 | xargs kill -9
## Windows Platform
Resolve Vite Port Conflict
For: Port 5173 Already in UseSteps:
- Check if another Vite development server is running
- Kill existing Vite processes if not needed
- Specify a custom port for your Vite server
- Configure permanent port in vite.config.js
netstat -ano | findstr :5173
# Summary
What it is: localhost:5173 is Localhost:5173 is the default development port for Vite, a fast build tool and development server for modern web projects. Vite provides lightning-fast hot module replacement and is commonly used with Vue, React, Svelte, and other frontend frameworks for optimized development experience.
Who uses it: Vite, Vite + Vue, Vite + React, Vite + Svelte, Vue 3 Applications, React + TypeScript, Svelte Kit, Vanilla JavaScript, Vite Plugin Ecosystem, Vitest, Storybook + Vite, Vite Preview Server, Electron + Vite, PWA with Vite
Access URL:
http://localhost:5173