美洲狮似乎并没有开放端口它说它是

美洲狮似乎并没有开放端口它说它是

问题描述:

我正在开发一个Rails应用程序使用Puma作为我的本地机器上的服务器。美洲狮似乎并没有开放端口它说它是

当我开始在本地服务器,日志清楚地表明,彪马在localhost:3011打开连接:

=> Booting Puma 
=> Rails 5.0.4 application starting in development on http://localhost:3011 
=> Run `rails server -h` for more startup options 
Puma starting in single mode... 
* Version 3.9.1 (ruby 2.3.4-p301), codename: Private Caller 
* Min threads: 5, max threads: 5 
* Environment: development 
* Listening on tcp://0.0.0.0:3000 
Use Ctrl-C to stop 

但是当我运行netstat看到开放的端口,端口3011似乎并没有被激活:

[email protected]:~/Programming$ netstat -an | grep "3011" 
(there is no output) 
[email protected]:~/Programming$ 

我该如何解决为什么我的本地服务器没有打开它说的端口?

+0

实验一些,我发现服务器正在监听端口3000.为什么它这样做,我该如何让它监听端口3011? – Kevin

=>为前缀的语句来自Rails,有时无法获得正确的信息。 You can see the source for that log statement here.

绑定端口真正重要的是美洲狮的绑定,这在日志中显示得较低。 You can see the source for that log here.您可以在几个不同的方式使这些工作:

  • 添加-p标志到服务器的命令:rails s -p 3000
  • 添加bind 'tcp://0.0.0.0:3000'config/puma.rb