ruby-on-railsservereventmachine

rails: port is in use or requires root privileges


I am getting this error when attempting to start up a rails 4.1.1 server:

Listening on 0.0.0.0:3000, CTRL+C to stop
Exiting
/Users/darrenburgess/.rvm/gems/ruby-2.1.2@myflix/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)

I have tried the following commands to find and kill the process, however none of them reveal any servers running on 3000

ps ax | grep rails
ps ax | grep ruby
lsof -i TCP | grep LISTEN
lsof -i :3000

These, from my research on stack overflow, seem to be all of the available methods for discovering running ports.

In a rails 5 application I am getting the following similar error:

Listening on tcp://0.0.0.0:3000
Exiting
/Users/darrenburgess/.rvm/gems/ruby-2.3.1/gems/puma-3.7.0/lib/puma/binder.rb:269:in `initialize': Address already in use - bind(2) for "0.0.0.0" port 3000 (Errno::EADDRINUSE)

Note that I can start rails servers on other ports.

This error persists even after machine reboot. Seems I have exhausted all avenues for finding and killing ports in use. What other things can I try?

UPDATE: @hjpotter92 suggests running:

netstat -lntp | grep 3000

This however does not work as an option is required for the p argument. According to man netstat the list of protocols is found in etc/protocols.

I looked in that file and found that tcp is a listed protocol. However, this command does not return any output:

netstat -lntp tcp | grep 3000

Nor does this command return anything either:

netstat -lnt | grep 3000

Solution

  • Well, it turns out the answer to this is fairly obscure. The Node instance of FileMaker server 16 is running on port 3000. I was running a FileMaker server on the my Rails development machine.

    This command helped to discover that:

    sudo lsof -P -i :3000
    

    Result

    node    562 fmserver   20u  IPv6 0x3ef1908b38776fe5      0t0  TCP *:3000 (LISTEN)
    

    I could kill that process, however elected instead to disable the Node instance (The FileMaker REST/Data API).

    Documentation here shows that FileMaker 16 is using that port. http://help.filemaker.com/app/answers/detail/a_id/16319