简体   繁体   English

地址已用于 puma-dev

[英]Address already in use for puma-dev

Problem问题

Whenever I try to run每当我尝试跑步时

bundle exec puma -C config/puma.rb --port 5000

I keep getting我不断得到

bundler: failed to load command: puma (/Users/ogirginc/.asdf/installs/ruby/2.7.2/bin/puma)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 5000

Tried Things尝试过的东西

I have tried anything I can think of or read.我已经尝试了任何我能想到或读到的东西。 Here is the list:这是清单:

1. Good old restart the mac. 1. 老好重启mac。

  • Nope.不。

2. Find PID and kill. 2.找到PID并杀死。

  • Run lsof -wni tcp:5000运行lsof -wni tcp:5000
COMMAND    PID     USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
ControlCe 6071 ogirginc   20u  IPv4 0x1deaf49fde14659      0t0  TCP *:commplex-main (LISTEN)
ControlCe 6071 ogirginc   21u  IPv6 0x1deaf49ec4c9741      0t0  TCP *:commplex-main (LISTEN)
  • Kill with sudo kill -9 6071 .sudo kill -9 6071

  • When I kill it, it is restarted with a new PID.当我杀死它时,它会以新的 PID 重新启动。

> lsof -wni tcp:5000
COMMAND    PID     USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
ControlCe 6071 ogirginc   20u  IPv4 0x1deaf49fde14659      0t0  TCP *:commplex-main (LISTEN)
ControlCe 6071 ogirginc   21u  IPv6 0x1deaf49ec4c9741      0t0  TCP *:commplex-main (LISTEN)

3. Use HTOP to find & kill 3. 使用HTOP来找杀

  • Filter with puma .puma过滤。
  • Found a match.找到了一个匹配。
PID USER      PRI  NI  VIRT   RES S CPU% MEM%   TIME+  Command
661 ogirginc   17   0  390G  6704 ?  0.0  0.0  0:00.00 /opt/homebrew/bin/puma-dev -launchd -dir ~/.puma-dev -d localhost -timeout 15m0s -no-serve-public-paths
  • Kill it with sudo kill -9 661 .sudo kill -9 661杀死它。
  • Restarted with a new PID.用新的 PID 重新启动。

Additional Info附加信息

  • rails version is 5.2.6 . rails 版本是5.2.6
  • puma version is 4.3.8 .美洲狮版本是4.3.8
  • puma-dev version is 0.16.2 . puma-dev 版本是0.16.2
  • Here are the logs for puma-dev:以下是 puma-dev 的日志:
2021/10/26 09:48:14 Existing valid puma-dev CA keypair found. Assuming previously trusted.
* Directory for apps: /Users/ogirginc/.puma-dev
* Domains: localhost
* DNS Server port: 9253
* HTTP Server port: inherited from launchd
* HTTPS Server port: inherited from launchd
! Puma dev running...

It feels like I am missing something obvious.感觉就像我错过了一些明显的东西。 Probably, due to lack of understanding some critical & lower parts of puma-dev .可能是由于缺乏对puma-dev一些关键和较低部分的了解。 I would really appreciate, if this is solved with some simple explanation.如果通过一些简单的解释来解决这个问题,我将不胜感激。 Thanks in advance!提前致谢! :) :)

Why为什么

Well, this is interesting.嗯,这很有趣。 It did not think of searching for lsof 's the COMMAND column, before.它之前没有想到要搜索lsofCOMMAND列。

Turns out, ControlCe is "Control Center" and with Monterey, macOS does listen ports 5000 & 7000 on default.事实证明, ControlCe是“控制中心”,对于 Monterey,macOS 会默认监听50007000端口。

Solution解决方案

  1. Go to System Preferences > Sharing转到系统偏好设置 > 共享
  2. Uncheck AirPlay Receiver .取消选中AirPlay Receiver
  3. Now, you should be able to restart puma as usual.现在,您应该可以像往常一样重新启动puma

Source: https://developer.apple.com/forums/thread/682332来源: https : //developer.apple.com/forums/thread/682332

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM