Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Batch's avatar
Level 1

Laravel Can't Connect to Postgresql

Hi,

When I try to connect postgresql server in my computer with Laravel I get "PDOException with message 'could not find driver'" error. I am getting this error when I run DB::connection()->getPdo(); command at artisan tinker. (If I run php artisan migrate command, the error is Illuminate\Database\QueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE'))

When I write a simple PHP code, I can connect to postgresql db by the way. This means the problem is not about my PHP or Postgresql installations. I am also able to connect to MySQL and SQLite with Laravel. So it seems the problem is about Laravel-PostgreSQL pair.

My configuration is below:

Windows 10
Wamp Server 3.1.4
Apache 2.4.35
PHP 7.2.10
Laravel Framework 6.0.3

Related lines of Laravel .env file:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=laravel_dnm1
DB_USERNAME=postgres
DB_PASSWORD=mrd.BE.265
0 likes
6 replies
mdl's avatar

Can you make sure that pdo_pgsql extension is enabled in your php configuration? The extension pgsql is not the pdo driver and you can keep it only if you have some legacy apps requiring it.

mdl's avatar

Is your CLI php configuration including it?

Can you paste the php -m dump?

Batch's avatar
Level 1

I think no. What should I do?

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
gettext
gmp
hash
iconv
imap
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
soap
sockets
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib
Batch's avatar
Level 1

Thanks for help. I solved the issue. It is a bug at WAMP I think. When I edit php.ini from WAMP's menu it opens a different php.ini than active PHP version's. So I opened php.ini from file system and edited it from there.

allyvinod's avatar

Thanks for the update. I have the same problem and modified the php.ini from the filesystem.

Please or to participate in this conversation.