Software⏱️ 3 min read📅 2026-06-04

How to Fix: Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL

Learn how to fix: Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL.

Quick Answer: Try checking your system settings or restarting.

Laravel developers may encounter an error when trying to connect to a PostgreSQL database, resulting in the 'Could not find driver' exception. This issue affects anyone who has recently switched from MySQL to PostgreSQL and is experiencing issues with php artisan migrate.

The frustration of this error lies in its misleading nature, leading users to believe that the problem lies within their code or configuration files when, in fact, it's a matter of incorrect database settings.

💡 Why You Are Getting This Error

  • The primary reason for this error is that Laravel's default configuration file is using MySQL as the database driver, despite being connected to PostgreSQL. This mismatch causes the 'Could not find driver' exception.
  • An alternative cause could be that the PostgreSQL extension is not installed or enabled on the system.

🔧 Proven Troubleshooting Steps

Configuring Laravel to Use PostgreSQL

  1. Step 1: Open the database.php file located in the config directory and update the 'mysql' connection settings to use PostgreSQL. Replace the 'driver' value with 'pgsql'.
  2. Step 2: Update the 'host', 'database', and 'username' values according to your PostgreSQL server configuration.
  3. Step 3: Save the changes to the database.php file and restart the server or run the migrations again.

Editing Laravel's Configuration Files Manually

  1. Step 1: Locate the .env file in the root directory of your project and update the 'DB_CONNECTION' value to 'pgsql'.
  2. Step 2: Update the 'DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USERNAME', and 'DB_PASSWORD' values according to your PostgreSQL server configuration.
  3. Step 3: Run the php artisan migrate command again to apply any pending migrations.

💡 Conclusion

By following these steps, you should be able to resolve the 'Could not find driver' exception in Laravel and successfully connect to your PostgreSQL database. Remember to verify that your PostgreSQL extension is installed and enabled on your system.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions