laravel/framework · error · InvalidArgumentException
Unsupported driver [{$driver}].
Error message
Unsupported driver [{$driver}]. What it means
Thrown by ConnectionFactory::createConnection() when the driver passed to it has no matching Connection subclass and no registered Connection::resolver. This is the connection-class counterpart to the connector error: it triggers after the PDO link was already built.
Source
Thrown at src/Illuminate/Database/Connectors/ConnectionFactory.php:314
* @param string $prefix
* @param array $config
* @return \Illuminate\Database\Connection
*
* @throws \InvalidArgumentException
*/
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
{
if ($resolver = Connection::getResolver($driver)) {
return $resolver($connection, $database, $prefix, $config);
}
return match ($driver) {
'mysql' => new MySqlConnection($connection, $database, $prefix, $config),
'mariadb' => new MariaDbConnection($connection, $database, $prefix, $config),
'pgsql' => new PostgresConnection($connection, $database, $prefix, $config),
'sqlite' => new SQLiteConnection($connection, $database, $prefix, $config),
'sqlsrv' => new SqlServerConnection($connection, $database, $prefix, $config),
default => throw new InvalidArgumentException("Unsupported driver [{$driver}]."),
};
}
}
View on GitHub (pinned to bd6b5437e6)
Solutions
- Use one of the built-in drivers (mysql, mariadb, pgsql, sqlite, sqlsrv).
- For a custom driver, register both halves: the connector binding AND Connection::resolver($driver, fn (...) => new YourConnection(...)).
- Correct the driver string typo in DB_CONNECTION / database.php.
- After fixing config, run php artisan config:clear.
Example fix
// before
ConnectionFactory - connector registered but no resolver; createConnection falls through.
// after
\Illuminate\Database\Connection::resolver('oci', fn ($conn, $db, $prefix, $config) => new \Acme\OracleConnection($conn, $db, $prefix, $config)); Defensive patterns
Strategy: validation
Validate before calling
$supported = ['mysql','mariadb','pgsql','sqlite','sqlsrv'];
if (! in_array($driver, $supported, true) && ! \Illuminate\Database\Connection::getResolver($driver)) {
throw new \RuntimeException("No Connection resolver for driver [$driver].");
} Type guard
function hasConnectionResolver(string $driver): bool {
return \Illuminate\Database\Connection::getResolver($driver) !== null;
} Prevention
- Register both a connector binding AND Connection::resolver() for custom drivers.
- Prefer built-in drivers when possible.
- Add a smoke test that opens one connection per configured driver.
- Keep connector and connection resolvers in the same service provider.
When it happens
Trigger: createConnector() succeeded (e.g. because a 'db.connector.{driver}' binding exists or the driver is recognized), but createConnection() cannot map the same driver to a Connection class. Happens when a package registers only the connector half of a driver, or when a driver name passes the connector list but not the connection list.
Common situations: Custom driver package that registered a connector but forgot Connection::resolver('oci', fn (...) => new OracleConnection); typo'd driver; mismatch between connector bindings and connection resolvers.
Related errors
- Unsupported driver [{$config['driver']}].
- Auth driver [{$config['driver']}] for guard [{$name}] is not
- Broadcast connection [{$name}] is not defined.
- Driver [{$config['driver']}] is not supported.
- Lost connection and no reconnector available.
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/821b159748adc5e0.json.
Report an issue: GitHub.