`fly launch` failing to launch rails app

I’m having trouble launching a Rails app.
It’s already attached to a postgres-db.

I have this in application.rb:

config.assets.initialize_on_precompile = false

It still fails with the following message:

I’m a bit stumped, any help is appreciated.

(base) railsapp $ flyctl launch
Update available 0.0.286 -> v0.0.292.
Run "flyctl version update" to upgrade.
An existing fly.toml file was found for app <app>
App is not running, deploy...
Deploying <app>
==> Validating app configuration
--> Validating app configuration done
Services
TCP 80/443 ⇢ 8080
Remote builder fly-builder-morning-silence-7594 ready
==> Building image with Buildpacks
--> docker host: 20.10.12 linux x86_64
20: Pulling from heroku/buildpacks
Digest: sha256:51612bddbbf4b5eff17149024bb7ad10d2d11e68fe81f13af6cf46f906f0cf28
Status: Image is up to date for heroku/buildpacks:20
20: Pulling from heroku/pack
Digest: sha256:64c0ab86ce2ec354f0f687c995f8dd75400ca078d03af1fb855366da1bd8bd4b
Status: Image is up to date for heroku/pack:20
===> DETECTING
heroku/ruby     0.1.3
heroku/procfile 0.6.2
===> ANALYZING
Previous image with name "registry.fly.io/<app>:cache" not found
===> RESTORING
===> BUILDING
-----> Installing bundler 2.2.21
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.7.5
-----> Loading Bundler Cache

###### WARNING:

       You have the `.bundle/config` file checked into your repository
        It contains local state like the location of the installed bundle
        as well as configured git local gems, and other settings that should
       not be shared between multiple checkouts of a single repo. Please
       remove the `.bundle/` folder from your repo and add it to your `.gitignore` file.

       https://devcenter.heroku.com/articles/bundler-configuration

-----> Installing dependencies using bundler 2.2.21
       Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=/layers/heroku_ruby/gems/vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       Fetching gem metadata from https://rubygems.org/
       Fetching gem metadata from https://rubygems.org/..........
       Fetching rake 13.0.6
       Installing rake 13.0.6
       Fetching zeitwerk 2.5.3
       Fetching concurrent-ruby 1.1.9
       Fetching builder 3.2.4
       Fetching minitest 5.15.0
       Installing zeitwerk 2.5.3
       Installing builder 3.2.4
       Fetching erubi 1.10.0
       Installing minitest 5.15.0
       Installing concurrent-ruby 1.1.9
       Fetching mini_portile2 2.7.1
       Installing erubi 1.10.0
       Installing mini_portile2 2.7.1
       Fetching racc 1.6.0
       Fetching crass 1.0.6
       Fetching rack 2.2.3
       Installing racc 1.6.0 with native extensions
       Installing crass 1.0.6
       Fetching nio4r 2.5.8
       Installing rack 2.2.3
       Installing nio4r 2.5.8 with native extensions
       Fetching websocket-extensions 0.1.5
       Fetching marcel 1.0.2
       Installing marcel 1.0.2
       Fetching mini_mime 1.1.2
       Installing mini_mime 1.1.2
       Fetching public_suffix 4.0.6
       Installing public_suffix 4.0.6
       Using bundler 2.2.21
       Fetching method_source 1.0.0
       Installing method_source 1.0.0
       Installing websocket-extensions 0.1.5
       Fetching thor 1.2.1
       Fetching bcrypt 3.1.16
       Installing thor 1.2.1
       Installing bcrypt 3.1.16 with native extensions
       Fetching msgpack 1.4.3
       Installing msgpack 1.4.3 with native extensions
       Fetching matrix 0.4.2
       Installing matrix 0.4.2
       Fetching regexp_parser 2.2.0
       Installing regexp_parser 2.2.0
       Fetching unf_ext 0.0.8
       Installing unf_ext 0.0.8 with native extensions
       Fetching mime-types-data 3.2022.0105
       Installing mime-types-data 3.2022.0105
       Fetching net-http-digest_auth 1.4.1
       Installing net-http-digest_auth 1.4.1
       Fetching connection_pool 2.2.5
       Installing connection_pool 2.2.5
       Fetching ntlm-http 0.1.1
       Installing ntlm-http 0.1.1
       Fetching webrick 1.7.0
       Installing webrick 1.7.0
       Fetching webrobots 0.1.2
       Installing webrobots 0.1.2
       Fetching childprocess 4.1.0
       Installing childprocess 4.1.0
       Fetching chronic 0.10.2
       Installing chronic 0.10.2
       Fetching cliver 0.3.2
       Installing cliver 0.3.2
       Fetching coderay 1.1.3
       Installing coderay 1.1.3
       Fetching multi_xml 0.6.0
       Installing multi_xml 0.6.0
       Fetching jwt 2.3.0
       Installing jwt 2.3.0
       Fetching redis 4.5.1
       Installing redis 4.5.1
       Fetching geocoder 1.7.3
       Installing geocoder 1.7.3
       Fetching headless 2.3.1
       Fetching hkdf 0.3.0
       Installing headless 2.3.1
       Installing hkdf 0.3.0
       Fetching http-2 0.11.0
       Fetching iso_country_codes 0.7.8
       Installing iso_country_codes 0.7.8
       Fetching murmurhash3 0.1.6
       Installing murmurhash3 0.1.6 with native extensions
       Installing http-2 0.11.0
       Fetching pmap 1.1.1
       Installing pmap 1.1.1
       Fetching rbcat 0.2.1
       Installing rbcat 0.2.1
       Fetching rexml 3.2.5
       Installing rexml 3.2.5
       Fetching rubyzip 2.3.2
       Installing rubyzip 2.3.2
       Fetching multi_json 1.15.0
       Installing multi_json 1.15.0
       Fetching pg 1.2.3
       Installing pg 1.2.3 with native extensions
       Fetching rainbow 3.1.1
       Installing rainbow 3.1.1
       Fetching semantic_range 3.0.0
       Installing semantic_range 3.0.0
       Fetching turbolinks-source 5.2.0
       Installing turbolinks-source 5.2.0
       Fetching i18n 1.8.11
       Installing i18n 1.8.11
       Fetching tzinfo 2.0.4
       Installing tzinfo 2.0.4
       Fetching sentry-ruby-core 5.0.0
       Installing sentry-ruby-core 5.0.0
       Fetching rack-test 1.1.0
       Installing rack-test 1.1.0
       Fetching sprockets 4.0.2
       Installing sprockets 4.0.2
       Fetching rack-proxy 0.7.2
       Installing rack-proxy 0.7.2
       Fetching mail 2.7.1
       Installing mail 2.7.1
       Fetching addressable 2.8.0
       Installing addressable 2.8.0
       Fetching websocket-driver 0.7.5
       Installing websocket-driver 0.7.5 with native extensions
       Fetching nokogiri 1.13.1 (x86_64-linux)
       Fetching puma 5.5.2
       Installing nokogiri 1.13.1 (x86_64-linux)
       Installing puma 5.5.2 with native extensions
       Fetching mime-types 3.4.1
       Installing mime-types 3.4.1
       Fetching net-http-persistent 4.0.1
       Installing net-http-persistent 4.0.1
       Fetching whenever 1.0.0
       Installing whenever 1.0.0
       Fetching pry 0.14.1
       Installing pry 0.14.1
       Fetching redis-namespace 1.8.1
       Installing redis-namespace 1.8.1
       Fetching webpush 1.1.0
       Installing webpush 1.1.0
       Fetching net-http2 0.18.4
       Installing net-http2 0.18.4
       Fetching selenium-webdriver 4.1.0
       Installing selenium-webdriver 4.1.0
       Fetching bootsnap 1.10.2
       Installing bootsnap 1.10.2 with native extensions
       Fetching turbolinks 5.2.1
       Installing turbolinks 5.2.1
       Fetching activesupport 6.1.4.4
       Installing activesupport 6.1.4.4
       Fetching sentry-ruby 5.0.0
       Installing sentry-ruby 5.0.0
       Fetching unf 0.1.4
       Installing unf 0.1.4
       Fetching loofah 2.13.0
       Fetching xpath 3.2.0
       Installing loofah 2.13.0
       Installing xpath 3.2.0
       Fetching httparty 0.16.4
       Fetching rails-dom-testing 2.0.3
       Installing rails-dom-testing 2.0.3
       Installing httparty 0.16.4
       Fetching globalid 1.0.0
       Installing globalid 1.0.0
       Fetching activemodel 6.1.4.4
       Fetching domain_name 0.5.20190701
       Installing activemodel 6.1.4.4
       Installing domain_name 0.5.20190701
       Fetching rails-html-sanitizer 1.4.2
       Fetching capybara 3.36.0
       Installing rails-html-sanitizer 1.4.2
       Fetching activejob 6.1.4.4
       Installing capybara 3.36.0
       Installing activejob 6.1.4.4
       Fetching firebase_id_token 2.4.0
       Installing firebase_id_token 2.4.0
       Fetching http-cookie 1.0.4
       Installing http-cookie 1.0.4
       Fetching activerecord 6.1.4.4
       Installing activerecord 6.1.4.4
       Fetching actionview 6.1.4.4
       Installing actionview 6.1.4.4
       Fetching mechanize 2.7.7
       Installing mechanize 2.7.7
       Fetching poltergeist 1.18.1
       Installing poltergeist 1.18.1
       Fetching actionpack 6.1.4.4
       Installing actionpack 6.1.4.4
       Fetching jbuilder 2.11.5
       Installing jbuilder 2.11.5
       Fetching bitmask_attributes 1.0.0
       Installing bitmask_attributes 1.0.0
       Fetching composite_primary_keys 13.0.0
       Fetching capybara-mechanize 1.11.0
       Installing capybara-mechanize 1.11.0
       Installing composite_primary_keys 13.0.0
       Fetching actioncable 6.1.4.4
       Installing actioncable 6.1.4.4
       Fetching activestorage 6.1.4.4
       Fetching actionmailer 6.1.4.4
       Installing activestorage 6.1.4.4
       Installing actionmailer 6.1.4.4
       Fetching railties 6.1.4.4
       Fetching sprockets-rails 3.4.2
       Installing railties 6.1.4.4
       Installing sprockets-rails 3.4.2
       Fetching kimurai 1.4.0
       Installing kimurai 1.4.0
       Fetching actionmailbox 6.1.4.4
       Installing actionmailbox 6.1.4.4
       Fetching actiontext 6.1.4.4
       Installing actiontext 6.1.4.4
       Fetching sentry-rails 5.0.0
       Fetching rpush 7.0.0
       Fetching rails 6.1.4.4
       Installing rails 6.1.4.4
       Installing sentry-rails 5.0.0
       Installing rpush 7.0.0
       Fetching webpacker 5.4.3
       Fetching apipie-rails 0.5.19
       Installing webpacker 5.4.3
       Installing apipie-rails 0.5.19
       Bundle complete! 21 Gemfile dependencies, 109 gems now installed.
       Gems in the groups 'development,test' and 'production' were not installed.
       Bundled gems are installed into `/layers/heroku_ruby/gems/vendor/bundle`
       Post-install message from httparty:
       When you HTTParty, you must party hard!
       Post-install message from rubyzip:
       RubyZip 3.0 is coming!
       **********************

       The public API of some Rubyzip classes has been modernized to use named
       parameters for optional arguments. Please check your usage of the
       following classes:
         * `Zip::File`
         * `Zip::Entry`
         * `Zip::InputStream`
         * `Zip::OutputStream`

       Please ensure that your Gemfiles and .gemspecs are suitably restrictive
       to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
       See https://github.com/rubyzip/rubyzip for details. The Changelog also
       lists other enhancements and bugfixes that have been implemented since
       version 2.3.0.
       Post-install message from rpush:
       When upgrading Rpush, don't forget to run `bundle exec rpush init` to get all the latest migrations.

       For details on this specific release, refer to the CHANGELOG.md file.
       https://github.com/rpush/rpush/blob/master/CHANGELOG.md
       Bundle completed (20.31s)
       Cleaning up the bundler cache.
-----> Installing node-v12.16.2-linux-x64
-----> Installing yarn-v1.22.4
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: Connection refused
       	Is the server running on that host and accepting TCP/IP connections?
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:83:in `rescue in new_client'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_handling.rb:283:in `connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:553:in `load_schema!'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/attributes.rb:250:in `load_schema!'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:539:in `block in load_schema'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:536:in `synchronize'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:536:in `load_schema'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:392:in `columns_hash'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:60:in `block in valid?'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:60:in `all?'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:60:in `valid?'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:18:in `method_missing'
       /workspace/config/initializers/rpush.rb:142:in `<main>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:326:in `block in load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:299:in `load_dependency'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:326:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:681:in `block in load_config_initializer'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb:205:in `instrument'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:680:in `load_config_initializer'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:633:in `each'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:633:in `block in <class:Engine>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `instance_exec'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `run'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:61:in `block in run_initializers'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:50:in `each'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:50:in `tsort_each_child'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:60:in `run_initializers'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:391:in `initialize!'
       /workspace/config/environment.rb:5:in `<main>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:35:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `block in require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:299:in `load_dependency'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:367:in `require_environment!'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:533:in `block in run_tasks_blocks'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.0.0/lib/sentry/rake.rb:24:in `execute'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.0.0/lib/sentry/rake.rb:24:in `execute'

       Caused by:
       PG::ConnectionBad: connection to server at "127.0.0.1", port 5432 failed: Connection refused
       	Is the server running on that host and accepting TCP/IP connections?
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `new'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/connection_handling.rb:283:in `connection'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:553:in `load_schema!'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/attributes.rb:250:in `load_schema!'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:539:in `block in load_schema'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:536:in `synchronize'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:536:in `load_schema'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/model_schema.rb:392:in `columns_hash'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:60:in `block in valid?'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:60:in `all?'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:60:in `valid?'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.4/lib/active_record/dynamic_matchers.rb:18:in `method_missing'
       /workspace/config/initializers/rpush.rb:142:in `<main>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:326:in `block in load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:299:in `load_dependency'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:326:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:681:in `block in load_config_initializer'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb:205:in `instrument'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:680:in `load_config_initializer'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:633:in `each'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/engine.rb:633:in `block in <class:Engine>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `instance_exec'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `run'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:61:in `block in run_initializers'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:50:in `each'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:50:in `tsort_each_child'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:60:in `run_initializers'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:391:in `initialize!'
       /workspace/config/environment.rb:5:in `<main>'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:35:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `block in require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:299:in `load_dependency'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `require'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:367:in `require_environment!'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:533:in `block in run_tasks_blocks'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.0.0/lib/sentry/rake.rb:24:in `execute'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.0.0/lib/sentry/rake.rb:24:in `execute'
       Tasks: TOP => environment
       (See full trace by running task with --trace)

 !
 !     Precompiling assets failed.
 !     Attempted to access a nonexistent database:
 !     https://devcenter.heroku.com/articles/pre-provision-database
 !
ERROR: failed to build: exit status 1
Error executing lifecycle: failed with status code: 51

^ I get that it’s failing because it can’t connect to the db, but I thought it should’ve started working correctly when I set it up with Fly?

Jumped the gun with a wrong suggestion that’s now edited out. :tired_face:

Restoring my original post, as that seems to have been correct :slight_smile:

Hi,

In the DATABASE_URL, do you have 127.0.0.1:5432?
Try with pg-app-name.internal:5432 instead.

initialize_on_precompile was removed in Rails 4.0, so that won’t help, unfortunately. I thought this was a great feature :slight_smile:

Generally, initialization should not try to connect to the database unless something in an initializer needs a DB connection. You can see the error stems from:

config/initializers/rpush.rb:142

Did you already setup Rpush’s migrations? This issue may be related.

If you can’t find a way to stop Rpush from trying to access the database, you can try this trick:

Wrap your initializer:

if ENV['ASSET_COMPILE']
...
end

Then:

fly deploy --build-arg ASSET_COMPILE=1

Thank you, indeed it was the edited out suggestion.

I set the correct .internal DATABASE_URL in config/database.yml and now it’s working.

1 Like

Thank you @ronyf for confirming.
I’ve brought the original post back in that comment.
At least for a few seconds, answers from Fly employees make me feel extremely dumb lol.

Thanks @FrequentFlyer for the comments!

One more thing: most users will set the full database connection in a secret named DATABASE_URL. Otherwise, your database credentials will be visible in your code repository. You can do that with fly pg attach.

Rails will pick it up automatically without you needing to hard code anything in your database.yml.

I couldn’t tell the difference between pg attach and pg connect, so remained silent with that :stuck_out_tongue: