Why does my Node process fail with EADDRINUSE address already in use?
The error means something is already listening on the port your process tried to bind. The operating system allows only one listener per port and address combination, so the second attempt is refused. The question is always which process holds it, and there are a few recurring answers.
The most common is a previous run of the same application that did not shut down. This happens when a process was suspended rather than terminated, when a watcher or debugger left an orphan behind after a crash, or when a terminal was closed without the process receiving a signal. The old process is still running and still holding the port even though nothing appears to be attached to it.
On Linux and macOS you can identify the owner by listing open files filtered to that port, which reports the process ID and the command name. Windows offers the equivalent through its network statistics tool. Confirm what the process actually is before terminating it, since the port may legitimately belong to something else, particularly on common ports.
A container publishing the same host port produces the identical error, and is easy to overlook because nothing on the host itself appears to be listening. Listing running containers and their port mappings will show it.
Two subtler causes are worth knowing. Calling listen more than once in a single application, often after a refactor duplicated the startup path, fails the second time against your own process. Similarly, forking workers that each bind the same port without using a mechanism designed for sharing will fail for all but the first.
The durable fix for the orphan case is graceful shutdown. Handling termination signals and closing the server explicitly ensures the port is released when the process is asked to stop, which removes most of these incidents rather than requiring you to hunt down a stale process each time.