Fix: address already in use (EADDRINUSE)
Something is already listening on the port your program wants. Find the process with lsof or ss, stop it or pick another port. Often it is a previous copy of your own app, a container, or a system service.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
Error: listen EADDRINUSE: address already in use :::3000
OSError: [Errno 98] Address already in use
bind: address already in use
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Only one program can listen on a given address and port at a time. Yours asked the kernel for a port that another process already holds, so the bind call failed. The fix is always the same: find who holds the port, then stop it or move one of them.
Find the process holding the port
Check before you run this
- Runs with administrator rights. Make sure you understand every line.
# Linux
sudo ss -ltnp 'sport = :3000'
# LISTEN 0 511 *:3000 *:* users:(("node",pid=48213,fd=20))
# macOS and Linux
sudo lsof -nP -iTCP:3000 -sTCP:LISTEN
# COMMAND PID USER FD TYPE NODE NAME
# node 48213 alice 20u IPv6 TCP *:3000 (LISTEN)
# Windows
netstat -ano | findstr :3000
Cause 1: a previous copy of your own application
A dev server that did not shut down, a terminal tab you forgot, a debugger session still attached, or a process a file watcher such as nodemon left behind. Stop it politely first and only force it if it ignores you.
kill 48213 # SIGTERM, lets it clean up
sleep 2
kill -9 48213 # only if it is still there
# one-liner for the port you know
kill "$(lsof -t -iTCP:3000 -sTCP:LISTEN)"
Careful: check the process name before killing. A PID from lsof on port 5432 is probably your database, and killing it with -9 can lose in-flight writes.
Cause 2: a system service or container owns the port
Port 80 or 443 is usually Apache or nginx, 5432 PostgreSQL, 3306 MySQL, 6379 Redis, 8080 a Java app or a proxy. Docker publishes ports through docker-proxy and the container keeps running after your terminal closes.
Check before you run this
- Runs with administrator rights. Make sure you understand every line.
sudo systemctl stop nginx # stop the service, or change its port in its config
docker ps --format '{{.Names}}\t{{.Ports}}'
docker stop <container>
Cause 3: the port is in TIME_WAIT after a restart
Right after stopping a server, the kernel keeps the socket in TIME_WAIT for a minute. Programs that set SO_REUSEADDR (most frameworks do by default; Python’s socketserver needs allow_reuse_address = True) can rebind immediately. If you hit it in tests or scripts, wait a few seconds or let the server choose a free port (port 0) and read back which one it got.
Cause 4: wrong address, same port
127.0.0.1:3000 and 0.0.0.0:3000 conflict with each other, and on Linux an IPv6 :::3000 listener usually covers IPv4 too. Two services cannot share a port by using different host names on the same machine. Put one of them on another port, or front both with a reverse proxy that routes by host name.
PORT=3001 npm start # most Node apps read PORT
flask run --port 5001
uvicorn app:app --port 8001
Check that it is fixed
Check before you run this
- Runs with administrator rights. Make sure you understand every line.
sudo ss -ltnp 'sport = :3000' # empty, or shows only your new process
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/
When it is not what you think
EACCESorPermission deniedon bind means a privileged port below 1024 without root, not a busy port.EADDRNOTAVAILmeans the IP address you asked to bind to does not exist on this machine, for example a config copied from another server.- If
ssandlsofshow nothing but bind still fails, you may be inside a container or network namespace that differs from your shell, or a firewall or VPN client is reserving a port range (Windows Hyper-V does this:netsh interface ipv4 show excludedportrange protocol=tcp). - A port that frees itself only after a minute is TIME_WAIT, not a stuck process.
Official documentation
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0021 Read and write files in Node.js with fs/promises A complete Node script that walks a folder, reads text files, and writes a JSON report safely, showing the everyday fs/promises calls… Beginner · Step by step · Any system Script Node.js 15 Oct 2026
- 0022 Build a small Node.js CLI with util.parseArgs A complete, dependency-free command-line tool in Node: options and flags with parseArgs, input from files or a pipe, help text, and meaningful… Intermediate · Step by step · Any system Script Node.js 15 Oct 2026
- 0027 Fix: SyntaxError: Cannot use import statement outside a module The file uses ES module import syntax, but Node or the browser is loading it as a classic script or CommonJS. Tell… Intermediate · Fixes an error · Any system Article Common errors · Node.js 15 Oct 2026
- 0061 Fix: Address already in use (free a busy port) Your server cannot start because another process already listens on its port. This script shows which process holds the port and stops… Intermediate · Fixes an error · Linux, macOS Script Processes & ports · Shell scripting 15 Oct 2026
- 0103 Proxmox VE networking: Linux bridges (vmbr0) and VLANs Guests reach the network through Linux bridges such as vmbr0, defined in /etc/network/interfaces. Learn the default setup, VLAN-aware bridges, VLAN tags for… Intermediate · Step by step · Linux Article Installation & first steps · Networking & firewalls 15 Oct 2026
- 0167 Fix: Job for nginx.service failed because the control process exited with error code systemctl prints this when a service's start command exits with an error. The real reason is in journalctl; for nginx it is… Intermediate · Fixes an error · Linux Article Networking & firewalls · Services & systemd 15 Oct 2026
Repos in the wild
- Node.js nodejs/node The source of the Node.js runtime: a JavaScript engine (V8) plus APIs for files, networking, processes and more, used to run JavaScript outside the browser. GitHub
- Express (expressjs/express) expressjs/express A minimal and flexible web framework for Node.js, built around routes and middleware, and the foundation of countless APIs and other frameworks. GitHub
- firewalld: zone-based firewall daemon firewalld/firewalld Upstream source of firewalld, the default firewall manager on RHEL, Rocky Linux, AlmaLinux and Fedora, including firewall-cmd and its service definitions. GitHub
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +3,682 chars