4

我收到以下错误:

$rails server --binding=127.0.0.1
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://127.0.0.1:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-04-04 13:02:35] INFO  WEBrick 1.3.1
[2012-04-04 13:02:35] INFO  ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2012-04-04 13:02:35] WARN  TCPServer Error: Address already in use - bind(2)
Exiting
/Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:73:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
from /Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:73:in `new'
from /Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:73:in `block in create_listeners'
from /Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:70:in `each'
from /Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/utils.rb:70:in `create_listeners'
from /Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:74:in `listen'
from /Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:62:in `initialize'
from /Users/TravisKs/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:24:in `initialize'
from /Users/TravisKs/.rvm/gems/ruby-1.9.2-p290@rvm-gemset-name/gems/rack-1.3.5/lib/rack/handler/webrick.rb:10:in `new' 
from /Users/TravisKs/.rvm/gems/ruby-1.9.2-p290@rvm-gemset-name/gems/rack-1.3.5/lib/rack/handler/webrick.rb:10:in `run' 
from /Users/TravisKs/.rvm/gems/ruby-1.9.2-p290@rvm-gemset-name/gems/rack-1.3.5/lib/rack/server.rb:265:in `start'
from /Users/TravisKs/.rvm/gems/ruby-1.9.2-p290@rvm-gemset-name/gems/railties-3.1.1/lib/rails/commands/server.rb:70:in `start'
from /Users/TravisKs/.rvm/gems/ruby-1.9.2-p290@rvm-gemset-name/gems/railties-3.1.1/lib/rails/commands.rb:54:in `block in <top (required)>'
from /Users/TravisKs/.rvm/gems/ruby-1.9.2-p290@rvm-gemset-name/gems/railties-3.1.1/lib/rails/commands.rb:49:in `tap' 
from /Users/TravisKs/.rvm/gems/ruby-1.9.2-p290@rvm-gemset-name/gems/railties-3.1.1/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

重新启动我的机器后,我仍然有这个问题。我已经查看了有关 Rails 的 TCPServer 错误的其他 SO 帖子。

ps -eo pid,ppid,user,args,stat

不返回 rails 的结果

ps aux

不返回任何僵尸进程(stat 列中的 Z)或 Rails 服务器。

这对我来说很奇怪,因为一切正常。我切换了一个 gemset,重新安装了 Rails 3.1.1,但现在我无法运行它。

4

2 回答 2

8

尝试运行lsof | grep 3000,然后kill -9 <number of process> 如果没有帮助,请尝试运行带有-p 3001更改端口选项的 rails 服务器

于 2012-04-04T20:22:58.193 回答
1

好吧,我知道现在回答为时已晚,但是就在同一天,我遇到了同样的问题。

我所做的就是,重新启动我的机器。似乎其他应用程序正在使用相同的端口!..

所以,只需重新启动,问题就解决了!

于 2013-09-20T14:18:13.030 回答