localhost:3001

Nobody intentionally picks port 3001 — you end up here because port 3000 was already occupied. This happens constantly in full-stack development: your React frontend is on 3000, and now your Express API needs somewhere to live. Or you have two Node.js projects running simultaneously. Or Create React App detected 3000 was busy and asked "Would you like to run on another port instead?" — and you hit Y.

Port 3001 is the unofficial "secondary dev port" of the JavaScript ecosystem. There's nothing special about it technically — it's just 3000 + 1.

Quick Access: Open localhost:3001

The Common Setup: Frontend on 3000, Backend on 3001

The most typical reason for using 3001 is the full-stack development pattern:

# Terminal 1 — React/Next.js frontend
cd frontend
npm run dev
# Running on http://localhost:3000

# Terminal 2 — Express/Node.js backend API
cd backend
node server.js
# Running on http://localhost:3001

Or reversed — some developers put the backend on 3000 (it was there first) and the frontend on 3001. Either way works, but you'll need to handle CORS or set up a proxy.

Handling CORS Between 3000 and 3001

Browsers treat localhost:3000 and localhost:3001 as different origins (the port is part of the origin). Your frontend's fetch('/api/users') to the backend will get blocked by CORS unless you handle it.

Option 1: Proxy (recommended for development)

// Vite — vite.config.js
export default {
  server: {
    proxy: { '/api': 'http://localhost:3001' }
  }
}

// Next.js — next.config.js
async rewrites() {
  return [{ source: '/api/:path*', destination: 'http://localhost:3001/api/:path*' }]
}

Option 2: Enable CORS on the backend

// Express
const cors = require('cors');
app.use(cors({ origin: 'http://localhost:3000' }));

Explicitly Setting Port 3001

# Express/Node.js
const PORT = process.env.PORT || 3001;
app.listen(PORT);

# React (CRA) — .env file
PORT=3001

# Next.js
next dev -p 3001

# Vite
npm run dev -- --port 3001

Multiple Projects Running at Once

If you're working on microservices or multiple projects, you'll quickly run out of "nice" ports. A common convention:

PortService
3000Frontend (React/Next.js)
3001Backend API
3002Auth service / second API
5432PostgreSQL
6379Redis

Or use Docker Compose to manage everything with defined port mappings — each service gets its own container and port assignment in docker-compose.yml.