# Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found

**Code:** `ActiveRecord::ConnectionNotEstablished` · **Category:** Ruby / Rails · **Seen on:** Ruby

ActiveRecord has no database connection configured or established for this process.

## 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.yml` section for the env
- `DATABASE_URL` not set
- Forked workers reusing a closed connection
- Adapter gem missing (pg/mysql2)
- ActiveRecord used standalone without establish_connection

## Quick fix

1. Verify `database.yml` and `RAILS_ENV`
2. Set `DATABASE_URL` correctly
3. In forks use `ActiveRecord::Base.establish_connection` (or preload settings)

## Detailed fix by platform

### Rails

1. `bin/rails runner 'p ActiveRecord::Base.connection_db_config.configuration_hash.except(:password)'`

## How to diagnose

1. **Config** — Present for env?
2. **Fork** — Reconnected?
3. **Gem** — Adapter installed?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ruby/activerecord-connectionnotestablished)
