gpt4 book ai didi

ruby-on-rails - 如何在 Ubuntu 中释放端口

转载 作者:行者123 更新时间:2023-12-02 04:33:29 26 4
gpt4 key购买 nike

我想对 Rails 使用端口号 localhost:3000,并且该端口号已被其他进程占用,我如何释放此端口号?

我已经运行了这个命令

ruby abc/script/server

并面临这个错误

/usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
from /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `new'
from /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `block in create_listeners'
from /usr/lib/ruby/1.9.1/webrick/utils.rb:82:in `each'
from /usr/lib/ruby/1.9.1/webrick/utils.rb:82:in `create_listeners'
from /usr/lib/ruby/1.9.1/webrick/server.rb:82:in `listen'
from /usr/lib/ruby/1.9.1/webrick/server.rb:70:in `initialize'
from /usr/lib/ruby/1.9.1/webrick/httpserver.rb:45:in `initialize'
from /usr/lib/ruby/vendor_ruby/rack/handler/webrick.rb:10:in `new'
from /usr/lib/ruby/vendor_ruby/rack/handler/webrick.rb:10:in `run'
from /var/www/abc/vendor/rails/railties/lib/commands/server.rb:111:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from abc/script/server:3:in `<main>'

最佳答案

netstat -tuln | grep 3000 - 会给你进程的PID

例如:

tcp    0   0 0.0.0.0:3000    0.0.0.0:*  LISTEN      5726/ruby1.9.1 

这里5726是PID,使用kill -9 5726杀死它

关于ruby-on-rails - 如何在 Ubuntu 中释放端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22496581/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com