netstat -ano | findstr :PORT_NUMBER
taskkill /PID PID_NUMBER /F
for /f "tokens=5" %a in ('netstat -aon ^| findstr :3000') do taskkill /PID %a /F
sudo lsof -i :PORT_NUMBER
sudo netstat -tulpn | grep :PORT_NUMBER
sudo kill -9 PID_NUMBER
sudo kill -9 $(sudo lsof -t -i:3000)
lsof -i :PORT_NUMBER
kill -9 PID_NUMBER
kill -9 $(lsof -t -i:3000)
Change the port in your application:
const PORT = process.env.PORT || 3001;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
Or set environment variable:
PORT=3001 npm start
React will automatically suggest the next available port, or you can specify:
PORT=3001 npm start
(Mac/Linux)set PORT=3001 && npm start
(Windows)
Change port in application.properties:
server.port=8081
Or use command line:
java -jar app.jar --server.port=8081
Specify a different port when running:
python manage.py runserver 8001
Change the port in your app:
app.run(port=5001)
Or use command line:
flask run --port 5001
Port | Common Use | Alternative Ports |
---|---|---|
3000 | React, Express, Rails | 3001, 3002, 3003 |
8080 | Spring Boot, Tomcat | 8081, 8082, 8090 |
5000 | Flask, .NET Core | 5001, 5002, 5003 |
8000 | Django, PHP | 8001, 8002, 8003 |
4200 | Angular | 4201, 4202, 4203 |
5173 | Vite.js | 5174, 5175, 5176 |