6

I have a Sinatra app that I run as a daemon, using Apache port-forwarding to mediate between port 80 and port 7655. This has been working fine in the past. Today, not so well. I cannot figure out why.

Problem: sudo ruby my_process.rb returns:

/var/lib/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)

Tried: updating all system packages, updating all gems. No help (except for the more clear error message from eventmachine).

When I run sudo lsof -i :7655 I get nothing back. When I run sudo ps aux I don't see any Ruby processes at all. Which I find highly irregular, given the nature of the error message!

So is there something I'm missing in finding out why the port is unavailable?


Also:

Tried changing ports, nothing. I wonder if it is related to "localhost"? When I ping localhost I get all dropped packets. That doesn't seem normal.

2
  • 1
    What exactly are you using to run my_process.rb?
    – pje
    Sep 30, 2012 at 16:29
  • Sorry, should have read sudo ruby my_process.rb
    – mlibby
    Sep 30, 2012 at 22:03

2 Answers 2

3

Turns out these two lines in the main Sinatra script provided the most information:

set bind: "localhost"
set port: 7655

The problem was with localhost. The loopback interface was not properly configured. ifconfig showed the lo interface, but it hadn't been assigned the IP 127.0.0.1. To resolve, ran the following commands in the shell (on an Ubuntu Linux system):

ifdown lo
ifup lo
3
  • can you provide a bit more detail about this answer. Where did you put "ifdown lo" and "ifup lo" if that's the solution. I can't figure out what to do... Dec 27, 2012 at 6:11
  • @BrainLikeADullPencil: "ifdown" AND "ifup" are Linux/MacOS commands to start and stop the "loopback" ("software") network adapter. They should not be necessary for your question. The key thing is to change the "bind" address in your Sinatra script, and see if it helps the "port in use" error you're currently getting for port#4567.
    – paulsm4
    Dec 28, 2012 at 3:51
  • @paulsm4 thanks, but i've never had to set a bind address before, and setting it now isn't working. I updated the OP with a little more information which may explain the source of the problem even if I cant' see the solution. Dec 28, 2012 at 4:21
0

When you close term sometime you forget to stop [CTRL+C] the actual server, just run the following command to kill all ruby process like sinatra, and run-it again

killall ruby

You can see your actual ruby process by running

ps -ef | grep ruby

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.