TCPServer Error: Address already in use - bind(2)

Type this in your terminal to find out the PID of the process that's using the 3000 port:

$ lsof -wni tcp:3000

Then, use the number in the PID column to kill the process:

$ kill -9 PID

I was not qualified to post comment. So I added a new answer.

I encountered this problem on Mac OS X 10.10.3. And I had never installed/used Jekyll before. I was not able to start jekyll server with its default port number 4000. The reason was that the port was the same as what NoMachine used. With

$ sudo lsof -wni tcp:4000

Note: Running this command without sudo will have no output.

I saw this output:

COMMAND PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
nxd     449   nx    3u  IPv4 0x8d22************      0t0  TCP *:terabase (LISTEN)
nxd     449   nx    4u  IPv6 0x8d22************      0t0  TCP *:terabase (LISTEN)

The port 4000 was occupied by nxd, which was the process started by NoMachine. And

$ sudo kill -9 449

would not work, because NoMachine's nxd process would keep restarting, with a new PID.

Therefore, I had to either:

  • Changed my jekyll server port in the site _config.yml to another spared one. I appended the line below to _config.yml and it worked.

    port: 3000 # change server port to 3000

or

  • Changed NoMachine's default nxd port, or Uninstall NoMachine

Ctrl-Z doesn't terminate a program, but rather suspends it and sends it to the background. You can resume the program with the "fg" command. To actually terminate it, use Ctrl-C.

The actual error message seems to be bogus and can be ignored. I am getting the same error message "address in use" but jekyll works fine anyway at the expected port.

Tags:

Ruby

Jekyll