Resolving listen EACCES Permission Denied 0.0.0.0:3000

October, 14th 2023 3 min read

When running a Node.js app on Windows, you may run into an error saying:

plaintext
Error: listen EACCES: permission denied 0.0.0.0:3000

This means your system blocked Node.js from using that port. The good news: it’s usually easy to fix. Below are the most common and reliable solutions.


Why This Error Happens

Node.js throws EACCES when:

  • The port requires elevated permissions
  • Another process already uses the port
  • Windows NAT / networking services are stuck
  • System TCP ranges are misconfigured

Ports below 1024 often require admin rights. Even higher ports (like 3000) can fail if Windows services misbehave or other apps occupy the port.


Solution 1: Change the Port (Fastest Fix)

Ports below 1024 may require elevated permissions, and port 3000 is often used by other tools (Next.js, React dev server, Vite, etc.). Switching to another port works in 99% of cases.

Plain Node.js HTTP Server

js
import http from 'http';

const PORT = process.env.PORT || 4000;

const server = http.createServer((req, res) => {
  res.end('Hello from Node');
});

server.listen(PORT, '0.0.0.0', () => {
  console.log(\`Server running at http://localhost:\${PORT}\`);
});

Express.js

js
import express from 'express';

const app = express();
const PORT = process.env.PORT || 4000;

app.get('/', (req, res) => res.send('Hello from Express'));

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

NestJS — edit main.ts

ts
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const PORT = process.env.PORT || 4000;
  await app.listen(PORT, '0.0.0.0');
}
bootstrap();

Next.js — update package.json

json
{
  "scripts": {
    "dev": "next dev -p 4000",
    "start": "next start -p 4000"
  }
}

Vite / React / TanStack Router

json
{
  "scripts": {
    "dev": "vite --port 5174",
    "preview": "vite preview --port 4174"
  }
}

Hono (Node.js or Bun)

ts
import { Hono } from 'hono';
import { serve } from '@hono/node-server';

const app = new Hono();
const PORT = Number(process.env.PORT) || 4000;

serve({ fetch: app.fetch, port: PORT });

Angular

plaintext
ng serve --port 4300

Solution 2: Restart Windows NAT (Fixes Most Port/Bind Issues)

Run PowerShell as Administrator:

plaintext
net stop winnat

Then reset TCP dynamic ports:

plaintext
netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384

Restart the service:

plaintext
net start winnat

This often fixes hidden Windows networking bugs that block Node.js ports.


Solution 3: Free the Port (If Another App Uses It)

Check what process is using port 3000:

plaintext
netstat -ano | findstr :3000

Kill it:

plaintext
taskkill /PID <id> /F

Solution 4: Run Terminal as Administrator

Sometimes the issue is simply lack of permissions.

Right‑click → Run as Administrator → start your project again.


Solution 5: Use a Reverse Proxy (Production)

In production, apps rarely bind directly to port 80/443.
Use:

  • Nginx
  • Caddy
  • Apache

Your Node.js app listens on 3000/8080 internally while Nginx handles public traffic.


Conclusion

The listen EACCES error is common, especially on Windows. Most of the time, switching the port or restarting NAT fixes it instantly. If not, check which process is using the port or run your terminal with admin permissions. After applying these steps, your Node.js server should run normally without permission errors.