Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found
ActiveRecord has no database connection configured or established for this process.
ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' foundActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)Could not find adapter for databaseActiveRecord::AdapterNotSpecified: database configuration does not specify adapter Meaning
Check config/database.yml for the current RAILS_ENV, that DATABASE_URL is set, the connection isn't broken in forked processes (Puma/Unicorn/Sidekiq: reconnect after fork), and the adapter gem is installed. Also seen when using ActiveRecord outside Rails without establish_connection.
Common causes
- Missing/invalid
database.ymlsection for the env DATABASE_URLnot set- Forked workers reusing a closed connection
- Adapter gem missing (pg/mysql2)
- ActiveRecord used standalone without establish_connection
⚡ Quick fix
- Verify
database.ymlandRAILS_ENV - Set
DATABASE_URLcorrectly - In forks use
ActiveRecord::Base.establish_connection(or preload settings)
Detailed fix by platform
Rails
bin/rails runner 'p ActiveRecord::Base.connection_db_config.configuration_hash.except(:password)'
How to diagnose
- Config — Present for env?
- Fork — Reconnected?
- Gem — Adapter installed?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- A server is already running. Check /tmp/pids/server.pid Rails: A server is already running (pid: 12345, file: /app/tmp/pids/server.pid). Exiting
- AbstractController::DoubleRenderError Rails: AbstractController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action)
- ActionController::InvalidAuthenticityToken Rails: ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity)
Most viewed in Ruby / Rails
- ActiveRecord::PendingMigrationError Rails: ActiveRecord::PendingMigrationError — Migrations are pending. To resolve this issue, run: bin/rails db:migrate
- undefined method for nil Ruby: NoMethodError: undefined method `x' for nil (nil:NilClass)
- Bundler could not find compatible versions for gem Bundler: Bundler could not find compatible versions for gem "activesupport": In Gemfile: rails (= 7.1.0) depends on activesupport (= 7.1.0)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026