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.
| What you see | Meaning | First thing to try |
|---|---|---|
| Browser: localhost refused to connect | Nothing is listening on port 3000 | Start the dev server and read the URL it prints |
| Terminal: EADDRINUSE :::3000 | Another process already uses port 3000 | Find that process and stop it, or use another port |
| Page loads, but an old app appears | A different project's server is still running | Stop 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> /FRun 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 3001Default dev server ports
| Tool | Command | Default URL |
|---|---|---|
| Next.js | next dev / next start | http://localhost:3000 |
| Express hello world example | node app.js | http://localhost:3000 |
| Ruby on Rails | bin/rails server | http://localhost:3000 |
| Vite | vite | http://localhost:5173 |
| Vite preview | vite preview | http://localhost:4173 |
| Astro | astro dev | http://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.
Fixes by stack
Next.js: next dev stops on a syntax error in next.config.js or a missing dependency, so the port never opens; run npm install and read the first error. Create React App: npm start asks to use 3001 when 3000 is busy, so check which port you agreed to. Express: the app must call app.listen, and a crash in a route only shows up in the terminal.
Rails: bin/rails server refuses to start while tmp/pids/server.pid is left over from a crash; delete that file. Docker and WSL 2: the server inside must listen on 0.0.0.0 and the port must be forwarded, otherwise the browser on your machine is refused even though the app is running.
How it works
- Enter the port number your app uses. It defaults to 3000.
- Copy the find command for your system and run it in a terminal to see which process is listening.
- Stop that process with the second command, or start your app on a different port.
- If nothing is listening at all, check the table of default ports to be sure your tool really uses 3000.
Tips
- Read the URL the dev server prints when it starts. Vite, for instance, uses 5173 and moves to the next free port if that one is taken.
- Stop dev servers with Ctrl+C in their terminal instead of closing the window, which can leave the process running.
- Use http, not https, unless you started the server with HTTPS on purpose; Next.js only serves HTTPS locally with --experimental-https.
- Inside Docker, the app must listen on 0.0.0.0 and the port must be published, or localhost on the host machine will refuse the connection.
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, localhost:5173 (Vite), localhost:8080, localhost:8000.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- localhost:3001 (and 3002): Why the Port Changed
- localhost:4000: Jekyll, Phoenix and Apollo
- localhost:4200: Fixing the Angular Dev Server
- localhost:47990: Sunshine's Admin Page
- localhost:5000: Flask, .NET and the macOS AirPlay Clash
- localhost:5005: Debugging Java and Running Rasa
- localhost:5173: Fixing the Vite Dev Server Address
- localhost:5678: Running the n8n Editor
Related guides
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App