Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't open rails server

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

like image 267
hlim Avatar asked Aug 11 '11 20:08

hlim


3 Answers

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

like image 146
fl00r Avatar answered Nov 03 '22 22:11

fl00r


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

like image 37
ducktyped Avatar answered Nov 03 '22 23:11

ducktyped


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
like image 1
Dinesh Pallapa Avatar answered Nov 03 '22 22:11

Dinesh Pallapa