TCPServer Error: Address already in use - bind(2)
Solution 1
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
Solution 2
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
Solution 3
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.
Solution 4
I have met this problem recently.
I tried out all the method mentioned above, and even restarted my computer, but still couldn't solve it!!! Then I removed the jekyll and installed a new version, it just worked.
gem uninstall jekyll & gem install jekyll
(maybe you need super user priviledge).
If you really get annoyed with similar bugs, this sb method is worth a try...
Comments
-
Omnipresent almost 4 years
Jekyll was working fine for me few weeks back but now all of a sudden it gives me the following error:
TCPServer Error: Address already in use - bind(2) INFO WEBrick::HTTPServer#start: pid=7300 port=4000 % lsof -i :4000 <fetches nothing>
Even though nothing is running on the port. Below are the details:
% jekyll --version Jekyll 0.11.2 % where jekyll /home/bhaarat/.rvm/gems/ruby-1.9.2-p290/bin/jekyll /usr/bin/jekyll % ruby --version ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] % rvm --version rvm 1.10.0
Here is the output
% jekyll --server Configuration from /home/bhaarat/blog/omnipresent.github.com/_config.yml Auto-regenerating enabled: /home/bhaarat/blog/omnipresent.github.com -> /home/bhaarat/blog/omnipresent.github.com/_site [2012-04-21 13:46:40] regeneration: 38 files changed [2012-04-21 13:46:40] INFO WEBrick 1.3.1 [2012-04-21 13:46:40] INFO ruby 1.9.2 (2011-07-09) [i686-linux] [2012-04-21 13:46:40] WARN TCPServer Error: Address already in use - bind(2) [2012-04-21 13:46:40] INFO WEBrick::HTTPServer#start: pid=7382 port=4000
I know the address isn't in use and jekyll is probably breaking for some other reason but throwing that error. What are my options? I've tried re-installing as well.