首页 > 解决方案 > .rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in `listen': 地址已经在使用中-listen(2) (Errno::EADDRINUSE)

问题描述

几天前,我从 Mac 更改为 Linux (Ubuntu),并从 GitHub 的团队项目中克隆了 repo。(在此之前它与 Mac 一起工作)。但是现在,我遇到了这个问题。

我试图通过运行在本地 Unix 套接字(3000)上启动服务器

bundle exec puma

但它向我显示了这些错误。

[3217] Puma starting in cluster mode...
[3217] * Version 4.3.3 (ruby 2.6.5-p114), codename: Mysterious Traveller
[3217] * Min threads: 1, max threads: 16
[3217] * Environment: development
[3217] * Process workers: 1
[3217] * Preloading application
Traceback (most recent call last):
        13: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
        12: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
        11: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/puma:23:in `<main>'
        10: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/puma:23:in `load'
         9: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/bin/puma:10:in `<top (required)>'
         8: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/cli.rb:80:in `run'
         7: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/launcher.rb:172:in `run'
         6: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/cluster.rb:413:in `run'
         5: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/runner.rb:161:in `load_and_bind'
         4: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:90:in `parse'
         3: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:90:in `each'
         2: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:151:in `block in parse'
         1: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in `add_unix_listener'
/home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in `listen': Address already in use - listen(2) (Errno::EADDRINUSE)

然后我尝试运行

bundle exec puma -C config/puma.rb -b tcp://127.0.0.1:3001

但服务器立即停止而不运行它。

[3263] Puma starting in cluster mode...
[3263] * Version 4.3.3 (ruby 2.6.5-p114), codename: Mysterious Traveller
[3263] * Min threads: 1, max threads: 16
[3263] * Environment: development
[3263] * Process workers: 1
[3263] * Preloading application
[3263] * Listening on tcp://127.0.0.1:3001
[3263] Use Ctrl-C to stop

我也尝试过这篇文章中给出的方法:地址已在使用中 - bind(2) (Errno::EADDRINUSE)

喜欢

lsof -wni tcp:3000

但没有显示任何东西让我杀死 Pid 进程。

有人可以帮忙吗?

这些是我正在使用的软件版本:

这是 config/puma.rb 中的代码

# vars
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"

# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RACK_ENV") { "production" }

# pidfile and state
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"

# Threads for serving requests
threads 1, 16

# Workers (cpu cores)
workers ENV.fetch("WEB_CONCURRENCY") { 1 }
preload_app!

# Unix socket to for nginix reverse proxy
bind "unix://#{shared_dir}/sockets/puma.sock"

# Port for local server use
port ENV.fetch("PORT") { 3000 }

# Debugging
debug

# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true

activate_control_app

rackup "#{app_dir}/config.ru"

标签: rubyrubygemsubuntu-18.04windows-subsystem-for-linuxpuma

解决方案


看起来您正在端口上运行另一个程序3000。当命令有一些结果时,使用命令运行lsof -i:3000和停止它。kill


推荐阅读