ruby-on-rails - 权限被拒绝 - bind(2) Errno::EACCES (Ruby on Rails, Webpack on PostgreSQL)
问题描述
我正在尝试使用 Webpacker 模块和设置为端口 5432(默认)的 PostgreSQL 数据库使用 Ruby on Rails 呈现我的页面 - 我与编译器进行了一些反复,但最终得到了错误访问。在完成我的防火墙设置并确保我的 PC 接受端口 5432 (TCP) 上的连接后,我的终端仍然出现 EACCESS:2 错误。
我已经尝试切换到几个不安全的网络,但它仍在发生。
我认为它要么是配置错误的 Webpacker 文件,要么是我的 Database.yml 设置不正确。我正在使用这些设置运行 RubyMine 内部测试环境。
dev_server:
https: false
host: localhost
port: 5432
public: localhost:5432
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
pretty: false
compile: true
allowedHosts: [
'localhost',
'localhost:3000',
'localhost:5432']
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
这是我的错误日志。
C:\Ruby26-x64\bin\ruby.exe C:/Users/Bruger/Desktop/hydac-rails/bin/rails server -b 127.0.0.1 -p 5432 -e development
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
=> Run `rails server --help` for more startup options
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 4.3.1 (ruby 2.6.6-p146), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
Exiting
Traceback (most recent call last):
22: from C:/Users/Bruger/Desktop/hydac-rails/bin/rails:4:in `<main>'
21: from C:/Users/Bruger/Desktop/hydac-rails/bin/rails:4:in `require'
20: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.2.1/lib/rails/commands.rb:18:in `<top (required)>'
19: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.2.1/lib/rails/command.rb:46:in `invoke'
18: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.2.1/lib/rails/command/base.rb:69:in `perform'
17: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
16: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
15: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
14: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:138:in `perform'
13: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:138:in `tap'
12: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:147:in `block in perform'
11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:39:in `start'
10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.1.2/lib/rack/server.rb:329:in `start'
9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/rack/handler/puma.rb:73:in `run'
8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/launcher.rb:172:in `run'
7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/single.rb:98:in `run'
6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/runner.rb:161:in `load_and_bind'
5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/binder.rb:90:in `parse'
4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/binder.rb:90:in `each'
3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/binder.rb:106:in `block in parse'
2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/binder.rb:229:in `add_tcp_listener'
1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/binder.rb:229:in `new'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.1/lib/puma/binder.rb:229:in `initialize': Permission denied - bind(2) for "127.0.0.1" port 5432 (Errno::EACCES)
Process finished with exit code 1
我不完全确定此时出了什么问题。
解决方案
在我看来,您正试图在与 postgresql 相同的端口上运行 webpack 开发服务器。我首先会检查您是否在该端口上运行了 postgesql 服务器。从上面的文件中删除对端口 5432 或 'localhost:5432' 之类的 URL 的所有引用webpacker.yml
,并恢复默认值,例如:
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: true
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: /node_modules/
推荐阅读
- javascript - POST 表单答案到外部 API 离子角度
- python - PySpark:检查某些列中的值是否在范围内
- php - 在侧边栏显示数据库中具有一定价值的数据
- reactjs - 覆盖 CRA 3.x 上的 webpack 配置而不弹出
- excel - Excel GET请求缓存?
- laravel - 如何添加自定义迁移文件和 ruu php artisan passport:install
- python - 基于条件的列组合
- javascript - 我们如何检查同一天的 2 个时间戳?
- reactjs - 何时使用 useEffect?
- c# - Web API 模型绑定字符串值到 Enum[]