localhost:3001

Port 3001 is commonly used as a secondary development server when port 3000 is already occupied. It's popular for running backend APIs alongside frontend servers, microservices, or multiple projects simultaneously.

Open dev server: http://localhost:3001

Common Uses for Port 3001

ScenarioPort 3000Port 3001
Full Stack AppReact FrontendExpress/Node API
MicroservicesAuth ServiceUser Service
TestingProduction BuildDev Server
Multiple ProjectsProject AProject B

Start Server on Port 3001

React (Create React App)

# Mac/Linux
PORT=3001 npm start

# Windows CMD
set PORT=3001 && npm start

# Windows PowerShell
$env:PORT=3001; npm start

# Or add to .env file
PORT=3001

Node.js / Express

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3001;

app.get('/api', (req, res) => {
  res.json({ message: 'API running on port 3001' });
});

app.listen(PORT, () => {
  console.log(`Server: http://localhost:${PORT}`);
});

Next.js

npx next dev -p 3001
# or
npm run dev -- -p 3001

Frontend-Backend Proxy Setup

When React runs on 3000 and API on 3001:

// package.json (React app)
{
  "proxy": "http://localhost:3001"
}

// Now fetch('/api/users') automatically 
// proxies to http://localhost:3001/api/users

CORS Configuration

// Express backend on 3001
const cors = require('cors');

app.use(cors({
  origin: 'http://localhost:3000',
  credentials: true
}));

Check What's Using Port 3001

# Mac/Linux
lsof -i :3001

# Windows
netstat -ano | findstr :3001

# Kill process
# Mac/Linux: kill -9 PID
# Windows: taskkill /F /PID PID

Troubleshooting

ProblemSolution
Port already in useKill existing process or use 3002
CORS errorsAdd CORS middleware or use proxy
Connection refusedCheck if server is actually running
API not respondingVerify correct port in fetch/axios calls