[英]Rails server not starting on Port 3000 “TCPServer Error: Permission denied - bind (2)”
[英]Ruby on Rails: Permission denied - bind(2) for “0.0.0.0” port 80 (Errno::EACCES)
rails server
。 結果是:
[3957] Puma starting in cluster mode...
[3957] * Version 3.10.0 (ruby 2.5.1-p57), codename: Russell's Teapot
[3957] * Min threads: 5, max threads: 5
[3957] * Environment: development
[3957] * Process workers: 4
[3957] * Preloading application
[3957] * Listening on tcp://0.0.0.0:80
Exiting
Traceback (most recent call last):
22: from bin/rails:4:in `<main>'
21: from bin/rails:4:in `require'
20: from /home/my_username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<top (required)>'
19: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
18: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
17: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
16: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
15: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
14: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
13: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
12: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:147:in `block in perform'
11: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:53:in `start'
10: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/server.rb:297:in `start'
9: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/rack/handler/puma.rb:69:in `run'
8: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/launcher.rb:183:in `run'
7: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/cluster.rb:397:in `run'
6: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/runner.rb:144:in `load_and_bind'
5: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:88:in `parse'
4: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:88:in `each'
3: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:105:in `block in parse'
2: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:270:in `add_tcp_listener'
1: from /home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:270:in `new'
/home/my_usernam/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.10.0/lib/puma/binder.rb:270:in `initialize': Permission denied - bind(2) for "0.0.0.0" port 80 (Errno::EACCES)
將puma配置為使用其他端口。
# config/puma.rb
port(ENV.fetch('PORT', 3000))
在生產中設置PORT=80
,在本地開發中未unset PORT
。
Rails默認在端口3000上監聽,您可能已更改了一些設置以使其在端口80上運行。 普通用戶不能打開低於1024的端口。– meagar♦
Permission denied - bind(2) for "0.0.0.0" port 80 (Errno::EACCES)
只有root
可以綁定低於1024的端口。請勿以root
用戶身份運行本地開發服務器! 而是將端口配置為1024以上。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.