localhost:3000: What It Is and How to Fix It

localhost:3000 is a web server running on your own computer and listening on port 3000. Next.js, the Express hello world example and Rails all default to that port. If the page refuses to connect, nothing is listening there. If the server will not start, another process already holds the port, and you can find and stop it.

Which error do you have?
What you seeMeaningFirst thing to try
Browser: localhost refused to connectNothing is listening on port 3000Start the dev server and read the URL it prints
Terminal: EADDRINUSE :::3000Another process already uses port 3000Find that process and stop it, or use another port
Page loads, but an old app appearsA different project's server is still runningStop it, then restart the right one

Updated

localhost always means this machine, and the number after the colon picks which program on it you are talking to. Most trouble with port 3000 comes from one of two opposite problems: no server is running there, or two servers want it at once. Type a port below to get the commands for your system.

Free up a port

Port: 3000

macOS and Linux

List the process listening on the port, then stop it by its PID (the second column).

lsof -i :3000 -sTCP:LISTEN
kill <PID>
# still running? force it
kill -9 <PID>

Windows (Command Prompt)

Show connections with their process IDs, filter by the port, then end that PID.

netstat -ano | findstr :3000
taskkill /PID <PID> /F

Run on another port instead

Leave the other process alone and start your app somewhere free.

next dev -p 3001
PORT=3001 node app.js
npm run dev -- --port 3001

Default dev server ports

Defaults from each tool's own documentation, October 2026
ToolCommandDefault URL
Next.jsnext dev / next starthttp://localhost:3000
Express hello world examplenode app.jshttp://localhost:3000
Ruby on Railsbin/rails serverhttp://localhost:3000
Vitevitehttp://localhost:5173
Vite previewvite previewhttp://localhost:4173
Astroastro devhttp://localhost:4321

Handle a busy port in your own server

Read the port from PORT and report EADDRINUSE clearly

A small Express server that falls back to 3000, and prints a readable message when the port is taken.

const express = require("express");
const app = express();
const port = Number(process.env.PORT) || 3000;

app.get("/", (req, res) => res.send("Hello"));

const server = app.listen(port, () => {
  console.log(`Listening on http://localhost:${port}`);
});

server.on("error", (err) => {
  if (err.code === "EADDRINUSE") {
    console.error(`Port ${port} is busy. Try PORT=${port + 1} node app.js`);
    process.exit(1);
  }
  throw err;
});

Ports in one paragraph

A computer can run many servers at once, so each one listens on a numbered port. Only one program can listen on a given port and address at a time, which is why starting a second server on 3000 fails with EADDRINUSE.

Port 3000 has no official meaning. It became a habit because popular tools picked it as their default, so it is also the port most likely to be taken by a server you forgot about.

Connection refused, step by step

First confirm a server is running: its terminal should show a ready message and a URL. If it exited with an error, fix that error first, since the browser cannot connect to a server that is not there.

Next compare ports. If the terminal says 5173 or 4321 and you typed 3000, the browser is knocking on an empty door. Finally, try 127.0.0.1:3000 in place of localhost:3000, which rules out name resolution to the IPv6 address when the server only listens on IPv4.

How it works

  1. Enter the port number your app uses. It defaults to 3000.
  2. Copy the find command for your system and run it in a terminal to see which process is listening.
  3. Stop that process with the second command, or start your app on a different port.
  4. If nothing is listening at all, check the table of default ports to be sure your tool really uses 3000.

Tips

Frequently asked questions

What is localhost:3000?

localhost is the name for your own computer, usually 127.0.0.1 or ::1, and 3000 is a port number. Together they address a server running locally, most often a development server for a web app. Nobody else on the internet can open your localhost URL.

Why does localhost:3000 say refused to connect?

No program is accepting connections on that port. The dev server may not be running, may have crashed with an error, or may be listening on a different port such as 5173. Check the terminal where you started it.

How do I fix port 3000 already in use?

Find the process holding the port with lsof on Mac or Linux, or netstat -ano on Windows, then stop it with kill or taskkill. Or start your app on another port, for example next dev -p 3001.

How do I change the port in Next.js?

Pass -p, as in next dev -p 4000, or set the PORT environment variable when you run the command. The Next.js docs note that PORT cannot be set inside a .env file, because the server starts before that file is read.

Can someone else open my localhost:3000?

Not through that address, because localhost on their machine means their own computer. To share it on your network, the server must listen on all interfaces and others use your machine's local IP address and port.

Related: Vite vs Next.js, Install Node.js and npm on Mac, HTTP status codes, Deploy a React app, npm commands cheat sheet.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap