EADDRINUSE error ("port already in use"): how to fix
What the EADDRINUSE error means
The EADDRINUSE error (from Error: Address already in use) happens when your application tries to "listen" on a port that is already being used by another process. In Node.js, the message usually looks like Error: listen EADDRINUSE: address already in use :::3000.
In short: port 3000 (or any other) is already taken, and two processes can't use the same port at the same time.
Why it happens
- You started the application twice without stopping the first one.
- A previous process crashed and got "stuck" holding the port.
- Another application on the same server already uses that port.
- You hardcoded a port (e.g.,
app.listen(3000)) instead of using the one provided by the environment.
How to fix it on your computer (local)
1. Identify the process using the port
On Linux or macOS:
lsof -i :3000
On Windows:
netstat -ano | findstr :3000
2. Kill the process (replace PID with the number that showed up)
On Linux or macOS: kill -9 PID
On Windows: taskkill /PID PID /F
The definitive fix: use the environment's port
Hardcoding the port is the most common cause of this problem in production. Instead of app.listen(3000), use the PORT environment variable:
const port = process.env.PORT || 3000;
app.listen(port);
That way the hosting environment sets the right port automatically and the conflict disappears.
How Square Cloud avoids this problem
On Square Cloud, each application runs in an isolated, dedicated environment — no other process "steals" your port. Just have your application respect the PORT variable and set the port in the squarecloud.app file; the deploy takes care of the rest.
Still getting the error?
If the application still won't start, review the start command in My application won't start: Verifying the start script.
Updated on: 06/13/2026
Thank you!
