【问题标题】:Permission denied - bind(2) Errno::EACCES (Ruby on Rails, Webpack on PostgreSQL)权限被拒绝 - bind(2) Errno::EACCES (Ruby on Rails, Webpack on PostgreSQL)
【发布时间】:2021-04-16 07:06:40
【问题描述】:

我正在尝试使用 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

我现在不完全确定出了什么问题。

【问题讨论】:

  • 能否请您澄清一下您上面列出的 yaml 文件的全名和路径(相对于您的 rails 应用程序)是什么?
  • 乍一看,在我看来,您可能正试图在同一个端口上同时运行您的 rails 应用程序和 postgres 数据库?
  • 我的 webpacker.yml 文件的当前路径是 root/config/webpacker.yml

标签: ruby-on-rails ruby postgresql webpack


【解决方案1】:

在我看来,您正试图在与 postgresql 相同的端口上运行 webpack 开发服务器。 我首先会检查您是否在该端口上运行了 postgesql 服务器。从上面的webpacker.yml 文件中删除对端口 5432 或 'localhost:5432' 等 URL 的所有引用,并恢复默认值,例如:

  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/

【讨论】:

  • 我在同一个端口上运行 devserver 和 PostgreSQL,但是在检查服务器是否正在运行并按照您的建议进行更改后,我收到密码验证错误。我已经在我的database.yml中声明我的用户名是postgres,这是我在安装postgreSQL软件时创建的用户,以及我创建该用户时使用的相同密码。
猜你喜欢
  • 1970-01-01
  • 2013-02-15
  • 2011-12-28
  • 1970-01-01
  • 2022-07-07
  • 2011-08-30
  • 2016-01-19
  • 2015-12-06
  • 1970-01-01
相关资源
最近更新 更多