PG :: ConnectionBad:使用乘客和铁路的Nginx服务器上的错误

时间:2017-09-09 02:03:52

标签: ruby-on-rails postgresql nginx passenger

我一直在努力解决这个问题,而且我没有选择。我已经阅读了有关谷歌类似情况的所有内容,此处有关于堆栈的功能。但似乎没有任何效果。 在出现问题之前我已经完成了很少的部署。 在我取下服务器并重新开始之前,我想看看这里是否有人可以帮助我。

我还没有域名,但我的计划是在IP:地址上运行它以进行测试。

这是/etc/nginx/sites-enabled/default

server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;


    passenger_enabled on;
    rails_env    production;
    root         /home/deploy/my_app/shared/public;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

注意:我对root /home/deploy/my_app/shared/public;行做了很多更改。例如/home/deploy/my_app/current/public;提供404错误

当我执行cap production deploy部署停止时,此处是来自cap production deploy --trace

的错误
    ** Execute deploy:migrate
00:22 deploy:migrate
      [deploy:migrate] Run `rake db:migrate`
** Invoke deploy:migrating (first_time)
** Invoke deploy:set_rails_env 
** Execute deploy:migrating
00:22 deploy:migrating
      01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate
      01 rake aborted!
      01 PG::ConnectionBad: could not connect to server: Connection refused
      01    Is the server running on host "138.68.133.93" and accepting
      01    TCP/IP connections on port 5432?
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initiali…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initiali…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresq…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `ne…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `ch…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `ac…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `bl…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `ch…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `bl…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `co…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `re…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_handling.rb:87:in `connection'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:916:in `initialize'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `new'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `up'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:801:in `migrate'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (r…
      01 /home/deploy/circular_ems/shared/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
      01 /home/deploy/.rbenv/versions/2.3.1/bin/bundle:23:in `load'
      01 /home/deploy/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
      01 Tasks: TOP => db:migrate
      01 (See full trace by running task with --trace)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@138.68.133.93: Exception while executing as deploy@138.68.133.93: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
    Is the server running on host "138.68.133.93" and accepting
    TCP/IP connections on port 5432?

以下是/etc/postgresql/9.5/main# nano postgresql.conf

的连接设置
# - Connection Settings -

#listen_addresses = 'localhost'         # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
port = 5432                             # (change requires restart)
max_connections = 100                   # (change requires restart)
#superuser_reserved_connections = 3     # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
                                        # (change requires restart)
#unix_socket_group = ''                 # (change requires restart)
#unix_socket_permissions = 0777         # begin with 0 to use octal notation
                                        # (change requires restart)
#bonjour = off                          # advertise server via Bonjour
                                        # (change requires restart)
#bonjour_name = ''                      # defaults to the computer name
                                        # (change requires restart)

# - Security and Authentication -

#authentication_timeout = 1min          # 1s-600s
ssl = true                              # (change requires restart)
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
                                        # (change requires restart)
#ssl_prefer_server_ciphers = on         # (change requires restart)
#ssl_ecdh_curve = 'prime256v1'          # (change requires restart)
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'          # (change requires restart)
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'         # (change requires restart)
#ssl_ca_file = ''                       # (change requires restart)
#ssl_crl_file = ''                      # (change requires restart)
#password_encryption = on
#db_user_namespace = off
#row_security = on

# GSSAPI using Kerberos
#krb_server_keyfile = ''
#krb_caseins_users = off

# - TCP Keepalives -
# see "man 7 tcp" for details

#tcp_keepalives_idle = 0                # TCP_KEEPIDLE, in seconds;
                                        # 0 selects the system default
#tcp_keepalives_interval = 0            # TCP_KEEPINTVL, in seconds;
                                        # 0 selects the system default
#tcp_keepalives_count = 0               # TCP_KEEPCNT;
                                        # 0 selects the system default

0 个答案:

没有答案