Tall Tales

Port already in use error message

December 26, 2019

Here’s the error developers often get. I found the solution via this StackOverflow link. BUt for Windows WSL2 users, like me, the solution was this handy Linux command (below).

First, the error

Error: listen EADDRINUSE: address already in use :::4000

Then, the fix

  1. lsof -i tcp:4000 (replace 4000 with whatever port you were using)
  2. When I did that, I got back the following:

    COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    node    2457 bill   23u  IPv6  20672      0t0  TCP *:4000 (LISTEN)
  3. Last step is to kill the PID - in this case, 2457.
  4. sudo kill 2457
  5. Problem fixed!
Bill Pliske

Written by Bill Pliske, who lives and works in the Arizona desert trying his best to stay cool.