can't open rails server
Asked Answered
B

3

14

I don't know what I did. I think I updated my Ruby on Rails. After updating it, I always get error when running $rails server.

output is

ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:73:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)

I would restart the console and run rails server and it would work fine for a couple of minutes but then it would stop responding and if I restart rails server it would give me that error again. I tried running on different port (rails s -p 9191) and it gives me the same problem.

Any Ideas what I did wrong? Thnx guys

Bedplate answered 11/8, 2011 at 20:0 Comment(0)
P
34

run it on other port:

rails s -p 3001

so it'll load on localhost:3001

or kill all ruby processes:

killall ruby

and then run rails s

Presentation answered 11/8, 2011 at 20:2 Comment(18)
when I tried rails s -p 3001, it work but then if i restarted it and run it again I would get the error "Already in use - bind(2) Errno::EADDRINUSE)...." I also tried killall ruby but didn't work. It's weird cause I also tried it on my other laptop and it's giving me the same error. Does it have to do with my router or something?Bedplate
and yes - it looks like something wrog with your localhost environmentPresentation
mac OS X (10.6.8). I would start rails server on different port and wouldn't give me errors and restart it right after and it would give me the error.Bedplate
so I believe it is network problem. Try to disconnect from your network and run rails in offlinePresentation
yea tried doing it offline. still the same error. This is version im running Rails 3.0.9 and ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]Bedplate
what does this return: ps aux | grep ruby and ps aux | grep railPresentation
ruby-1.9.2-p290/bin/ruby script/rails s AND ruby script/rails s -p 3002 AND ruby script/rails s -p 8080 AND ruby script/rails s -p 3001Bedplate
and sudo killall -9 ruby do nothing?Presentation
yea it doesn't seems to kill the process after doing sudo killall ruby then I did ps aux | grep ruby, it still show scripts/rails -p 3001, script/rails -p 9090 ..... wait sorry forgot to put -9 option yea it killed everything. Tried rails server but still same problemBedplate
ps aux | grap webrick or you use mongrel?Presentation
this is what I get from ps aux | webrick "56265 0.0 0.0 2435116 412 s000 R+ 1:42PM 0:00.00 grep webrick" no i don't think I use mongrelBedplate
these are some errors I get from running rails s "/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:73:in new'" and ".rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:73:in block in create_listeners'"Bedplate
I don't know. Try to update all your gems. Very strange. Looks like ctrl+c didn't stop webrick at all, so port is binded by itPresentation
reboot your machine - I get this problem from time to time on ubuntuCounty
I think my ctrl+c is not stoping rails server properly. Everytime I restart my server I need to manually "killall ruby" to start rails server again.Bedplate
oh man this is so stupid of me. I was using ctrl+z all this time to kill my server. I don't know why suddenly I was using ctrl+z instead of ctrl+x . Stupid of me. Thnx fl00r for your help. I feel so stupid now....Bedplate
So that's something, all the other answers I've seen just tell you how to kill the pid and add a new one.Bustard
killall ruby was not able to kill the process started in chrome by the Jetbrains IDE support - chrome.google.com/webstore/detail/jetbrains-ide-support/…Zealous
B
22

I think somehow your rails server is keep running after you close it. You can try as

ps aux | grep ruby

see pid and then kill that pid

kill -9 <pid>

Now you can restart your server using

rails s

Note: From next time onwards try using Ctrl D for terminating rails server. That might help

Billetdoux answered 12/8, 2011 at 6:44 Comment(0)
F
1

I too faced the issue it all because of ruby instances are not properly terminated.We can terminate processes running in the background by pids.

lsof -wni tcp:3000

It displays all running pids of ruby.and terminate that pids.

kill -9 PID

Or use

killall ruby
Fm answered 29/1, 2017 at 14:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.