I have a Rails 8.0.1 application (Ruby 3.3.4) that I’m deploying to Heroku. The code pushes successfully, but whenever I run:
heroku run rails db:migrate
I get this error:
ActiveRecord::ConnectionNotEstablished: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed
It seems Rails is trying to connect via a local PostgreSQL socket instead of using Heroku’s Postgres add-on. Locally, everything works fine with rails db:migrate. On Heroku, I already ran:
heroku addons:create heroku-postgresql:essential-0
…and the add-on was created successfully. My Gemfile includes:
gem "rails", "~> 8.0", ">= 8.0.1"
gem "pg", "~> 1.5"
# ...
Here’s my database.yml:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: brikex2_development
test:
<<: *default
database: brikex2_test
production:
primary: &primary_production
<<: *default
database: brikex2_production
username: brikex2
password: <%= ENV["BRIKEX2_DATABASE_PASSWORD"] %>
cache:
<<: *primary_production
database: brikex2_production_cache
migrations_paths: db/cache_migrate
queue:
<<: *primary_production
database: brikex2_production_queue
migrations_paths: db/queue_migrate
cable:
<<: *primary_production
database: brikex2_production_cable
migrations_paths: db/cable_migrate
I want help how to properly configure my project to solve the issue