I can’t config the postgresql db for deploy to platform.sh

Viewed 28

Hello when deploying my application on platform.sh, the deployment succeeds, but I see that the connection to the database is problematic. And actually, I don’t know how to do the configuration for Platform.sh

the error message:

Executing deploy hook for application lnclassapp
    W: Rails Error: Unable to access log file. Please ensure that /app/log/production.log exists and is writable (ie, make it writable for user and group: chmod 0664 /app/log/production.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
    W: rake aborted!
    W: ActiveRecord::ConnectionNotEstablished: could not connect to server: Connection refused
    W:      Is the server running on host "localhost" (127.0.0.1) and accepting
    W:      TCP/IP connections on port 5432?
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:83:in `rescue in new_client'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:283:in `connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:90:in `each'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
    W: /app/.global/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
    W: /opt/ruby/3.0/bin/bundle:23:in `load'
    W: /opt/ruby/3.0/bin/bundle:23:in `<main>'
    W: 
    W: Caused by:
    W: PG::ConnectionBad: could not connect to server: Connection refused
    W:      Is the server running on host "localhost" (127.0.0.1) and accepting
    W:      TCP/IP connections on port 5432?
    W: /app/.global/gems/pg-1.1.0/lib/pg.rb:56:in `initialize'
    W: /app/.global/gems/pg-1.1.0/lib/pg.rb:56:in `new'
    W: /app/.global/gems/pg-1.1.0/lib/pg.rb:56:in `connect'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/connection_handling.rb:283:in `connection'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:90:in `each'
    W: /app/.global/gems/activerecord-6.1.4.1/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
    W: /app/.global/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
    W: /opt/ruby/3.0/bin/bundle:23:in `load'
    W: /opt/ruby/3.0/bin/bundle:23:in `<main>'
    W: Tasks: TOP => db:migrate
    W: (See full trace by running task with --trace)

My production configuration:

 production:
  adapter: postgresql
  encoding: unicode
  database: main
  username: main
  password: main
  host: database.internal
  port: 5432
  timeout: 5000
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

how can I configure the DB connection on platform&sh?

0 Answers
Related