{"record":{"id":"702263771570408f","repo":"laravel/framework","slug":"database-connection-name-not-configured","errorCode":null,"errorMessage":"Database connection [{$name}] not configured.","messagePattern":"Database connection \\[(.+?)\\] not configured\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/DatabaseManager.php","lineNumber":226,"sourceCode":"        return $this->factory->make($config, $name);\n    }\n\n    /**\n     * Get the configuration for a connection.\n     *\n     * @param  string  $name\n     * @return array\n     *\n     * @throws \\InvalidArgumentException\n     */\n    protected function configuration($name)\n    {\n        $connections = $this->app['config']['database.connections'];\n\n        $config = $this->dynamicConnectionConfigurations[$name] ?? Arr::get($connections, $name);\n\n        if (is_null($config)) {\n            throw new InvalidArgumentException(\"Database connection [{$name}] not configured.\");\n        }\n\n        return (new ConfigurationUrlParser)\n            ->parseConfiguration($config);\n    }\n\n    /**\n     * Prepare the database connection instance.\n     *\n     * @param  \\Illuminate\\Database\\Connection  $connection\n     * @param  string  $type\n     * @return \\Illuminate\\Database\\Connection\n     */\n    protected function configure(Connection $connection, $type)\n    {\n        $connection = $this->setPdoForType($connection, $type)->setReadWriteType($type);\n\n        // First we'll set the fetch mode and a few other dependencies of the database","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/DatabaseManager.php#L208-L244","documentation":"Thrown by DatabaseManager::configuration() when neither the static config (database.connections.<name>) nor the dynamicConnectionConfigurations map contains an entry for the requested name. Every other operation (opening, purging, configuring a connection) needs the config array, so a null result is rejected early with the offending name.","triggerScenarios":"Calling DB::connection('reporting') when 'reporting' is not in database.connections and was not added via DB::addConnection($name, $config); referencing a connection name in a model's $connection property that is not configured.","commonSituations":"Typo in the connection name; env-specific connection missing from current config; stale config cache; referencing a read/write connection suffix that does not exist; multi-tenant code calling DB::connection($tenant) before registering it.","solutions":["Add the connection to config/database.php under database.connections.<name>.","If it is a runtime connection, register it first: DB::addConnection($name, $config) (or config()->set('database.connections.<name>', $config)) before calling DB::connection($name).","Check the exact name spelling and the value of database.default.","Clear the config cache after editing config: php artisan config:clear."],"exampleFix":"// before\nDB::connection('reporting')->table('sales')->get();   // not configured\n\n// after\nconfig(['database.connections.reporting' => ['driver' => 'pgsql', 'host' => '...', ...]]);\nDB::connection('reporting')->table('sales')->get();","handlingStrategy":"validation","validationCode":"if (is_null(config(\"database.connections.{$name}\"))\n    && ! array_key_exists($name, app('db')->getConnections())) {\n    throw new \\InvalidArgumentException(\"Connection '{$name}' is not configured.\");\n}","typeGuard":"function connectionConfigured(string $name): bool {\n    return ! is_null(config(\"database.connections.{$name}\"));\n}","tryCatchPattern":null,"preventionTips":["Register runtime connections via DB::addConnection($name, $config) before use.","Keep database.default and connection names consistent across config and code.","Run config:clear after editing config/database.php."],"tags":["database","connection-manager","configuration","laravel"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}