Eventmachine start_tcp_server no acceptor - 端口正在使用或需要root权限(RuntimeError)
Posted
技术标签:
【中文标题】Eventmachine start_tcp_server no acceptor - 端口正在使用或需要root权限(RuntimeError)【英文标题】:Eventmachine start_tcp_server no acceptor - port is in use or requires root privileges (RuntimeError) 【发布时间】:2015-08-11 17:53:32 【问题描述】:我已经有 3 天无法运行本地服务器了。重新启动我的电脑没有帮助。有几次,在反复尝试大约 40-50 次后,它随机工作 - 我不知道为什么。我尝试了一次不同的端口并且有效,但从那时起,没有端口工作。每次我尝试运行我的 rails 服务器时,我都会得到这个。
/Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.5/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.5/lib/eventmachine.rb:526:in `start_server'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/thin-1.5.1/lib/thin/backends/tcp_server.rb:16:in `connect'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/thin-1.5.1/lib/thin/backends/base.rb:55:in `block in start'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.5/lib/eventmachine.rb:187:in `call'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.5/lib/eventmachine.rb:187:in `run_machine'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.5/lib/eventmachine.rb:187:in `run'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/rack-1.6.1/lib/rack/handler/thin.rb:19:in `run'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/rack-1.6.1/lib/rack/server.rb:286:in `start'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/server.rb:80:in `start'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/colmtuite/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
当我运行 ps aux | grep rails
时,我得到了这个输出:
colmtuite 6422 0.0 0.0 2441988 668 s002 S+ 2:44am 0:00.00 grep rails
当我运行ps aux | grep ruby
时,我得到了这个输出:
colmtuite 13305 0.0 0.0 2423356 200 s000 R+ 8:15pm 0:00.00 grep ruby
我的端口是否因某种原因关闭?
【问题讨论】:
如果你用sudo
运行它会发生什么?
你的意思是运行'sudo ps aux | grep 轨道'?我得到了这个输出: colmtuite 17258 0.0 0.0 2450180 672 s000 S+ 1:53am 0:00.00 grep rails
对于'sudo ps aux | grep ruby' 我得到了这个输出: colmtuite 17286 0.0 0.0 2441988 676 s000 S+ 1:55am 0:00.00 grep ruby
不,我的意思是尝试使用sudo
命令运行您的本地服务器:) 然后您将知道问题是否与root权限或正在使用的端口有关。
我得到了这个输出:gist.github.com/colmtuite/9c7e11a17f51f273c0fe
【参考方案1】:
我也有同样的问题
这对我有用
$ ps ax | grep rails
然后使用进程ID杀死进程
$ kill -9 [process Id]
..
例子
$ kill -9 20496
..
重新启动服务器
【讨论】:
以上是关于Eventmachine start_tcp_server no acceptor - 端口正在使用或需要root权限(RuntimeError)的主要内容,如果未能解决你的问题,请参考以下文章
使用 EventMachine 和 RabbitMQ 的 RPC