laravel/framework · error · InvalidArgumentException
Unsupported driver [{$config['driver']}].
Error message
Unsupported driver [{$config['driver']}]. What it means
Thrown by ConnectionFactory::createConnector() when the configured 'driver' value does not match any of the built-in connectors (mysql, mariadb, pgsql, sqlite, sqlsrv) and no custom 'db.connector.{driver}' container binding exists.
Source
Thrown at src/Illuminate/Database/Connectors/ConnectionFactory.php:286
* @throws \InvalidArgumentException
*/
public function createConnector(array $config)
{
if (! isset($config['driver'])) {
throw new InvalidArgumentException('A driver must be specified.');
}
if ($this->container->bound($key = "db.connector.{$config['driver']}")) {
return $this->container->make($key);
}
return match ($config['driver']) {
'mysql' => new MySqlConnector,
'mariadb' => new MariaDbConnector,
'pgsql' => new PostgresConnector,
'sqlite' => new SQLiteConnector,
'sqlsrv' => new SqlServerConnector,
default => throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]."),
};
}
/**
* Create a new connection instance.
*
* @param string $driver
* @param \PDO|\Closure $connection
* @param string $database
* @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)) {View on GitHub (pinned to bd6b5437e6)
Solutions
- Correct the driver string to one of: mysql, mariadb, pgsql, sqlite, sqlsrv.
- If using a third-party driver, register it via $this->app->bind('db.connector.oci', fn () => new OracleConnector) before connecting.
- Check for typos/casing in DB_CONNECTION and config/database.php.
- Run config:clear if you recently changed the driver to discard stale cache.
Example fix
// before (.env) DB_CONNECTION=mysq // after DB_CONNECTION=mysql
Defensive patterns
Strategy: validation
Validate before calling
$supported = ['mysql','mariadb','pgsql','sqlite','sqlsrv'];
$driver = config('database.connections.'.$name.'.driver');
if (! in_array($driver, $supported, true) && ! app()->bound('db.connector.'.$driver)) {
throw new \RuntimeException("Driver [$driver] for [$name] is unsupported / unregistered.");
} Type guard
function isSupportedDriver(string $driver): bool {
return in_array($driver, ['mysql','mariadb','pgsql','sqlite','sqlsrv'], true);
} Prevention
- Whitelist driver strings in config validation.
- Register 'db.connector.{driver}' bindings before using third-party drivers.
- Beware casing and typos in DB_CONNECTION.
- Run config:clear after changing drivers.
When it happens
Trigger: Passing a config with a driver string the framework doesn't recognize, e.g. 'oci' (Oracle), 'odbc', 'mongodb', or a typo like 'mysq'. The match expression falls through to the default case.
Common situations: Using a third-party driver package (Oracle/DB2/MongoDB) without registering its connector; a typo in DB_CONNECTION; casing mismatch ('MySQL' vs 'mysql'); pointing at a driver constant that resolved to something unexpected.
Related errors
- Unsupported driver [{$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/ab7981240e83edfb.json.
Report an issue: GitHub.