Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Title: Solving Laravel PDOException: Could Not Find Driver Error With PostgreSQL Connection
Body:
In this comprehensive blog post, we'll explore the possible causes of the "PDOException: could not find driver" error when trying to connect your Laravel application with a PostgreSQL database. We'll also discuss troubleshooting methods and best practices for avoiding such issues in the future. Since you are already using WAMP on Windows 8.1, we will primarily focus on solutions applicable to that setup.
First things first, let's verify whether your PHP installation has the necessary extensions installed. The most relevant ones needed for PostgreSQL database connection are `pdo_pgsql` and `pgsql`. Open your `php.ini` file in the Apache, WAMP (from php folder), and PostgreSQL locations. Check if these two extension names are uncommented, as they should be enabled:
1. `extension=pdo_pgsql.dll`
2. `extension=pgsql.dll`
Now, check your extension path in the PHP configuration file (`php.ini`). The default path for Windows is usually:
`extension_dir = "c:/wamp/bin/php/php5.5.12/ext/"`, but you might have changed it earlier. Make sure to use this path or replace it with the correct one if needed. This will ensure that PHP can find these extensions.
Next, let's try a 'Path trick' in the system variables and reboot your machine to see if it resolves the issue:
1. Open 'Environment Variables' on Windows by searching for "Edit environment variables" or right-clicking on This PC > Properties > Advanced System Settings > Environment Variables.
2. Edit the PATH variable by adding `;C:\wamp\bin\php\php5.5.12` (or your PHP installation path) to the end of the existing value.
3. Restart your machine to apply this change.
If none of these steps solve the issue, you might need to manually install the pdo_pgsql and pgsql extensions. Follow these steps:
1. Go to https://laravelcompany.com/laracasts and search for "How to Install PDO_PDO and PDO_Pg Extensions". This tutorial will guide you through the process of installing both extensions on your machine. Be sure to select the appropriate PHP version based on your installation.
2. If you're not a fan of using Laracasts, follow these steps:
- Download the PHP source files for `php_pdo_driver.h` and `php_pdo.h` from https://www.postgresql.org/download/windows/. Move them to `C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\php\SDK\include\ext\pdo`.
- Download the required PDO_PDO and PDO_PG extensions from https://www.pmdb.net/search?q=pdo_pgsql.dll. Move them to `C:\wamp\bin\php\php5.5.12\ext` (or your PHP installation path).
- Open your php.ini file and uncomment the PDO_PDO and PDO_PG extensions. Enable 'zend_extension=ext/zend_optimizer.so' if needed.
Finally, don't forget to enable the PostgreSQL extension within Laravel by adding your connection details in `config/database.php`:
1. Create a new entry for your PostgreSQL database under 'pgsql'. This should include `driver` as 'pgsql', the hostname (typically localhost), username, password, database name, port number, and charset.
2. Set the default connection to use in Laravel's `config/app.php`. Keep in mind that you should set the fallback to either MySQL or SQLite since PostgreSQL is not a standard PHP database type.
Once all these steps are completed and you have verified your configuration, try running 'php artisan migrate' again. If the issue persists, check for other common Laravel errors, such as incorrect connection credentials, missing database tables, or incompatible table structures. You can consult comprehensive guides on troubleshooting Laravel errors to find a solution quickly.
To conclude, we have covered the most common causes and solutions for PDOException: could not find driver error with PostgreSQL connections in Laravel. By following these steps, you should be able to connect your application successfully. If none of these methods work, feel free to seek further assistance from community members or professional support. Good luck with your project!