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

dru's avatar
Level 3

Can't connect to local postgres database

I'm having some troubles trying to connect to a postgres database of an already existing laravel project done with mysql.

for the moment, I have this in my .env file:

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_SCHEMA=torrecontrol
DB_DATABASE=torrecontrol
DB_USERNAME=postgres
DB_PASSWORD=1234

and updated the file database.php

 'pgsql' => [
        'driver' => 'pgsql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'prefix_indexes' => true,
        'schema'   => env('DB_SCHEMA', 'public'),
        'sslmode' => 'prefer',
    ],

And I'm using those parameters to connect to postgres with a DBeaver (a database client).

but when I run the command: php artisan migrate, it gives me this error:

could not find driver (SQL: select * from information_schema.tables where table_schema = torrecontrol and table_name = 

migrations and table_type = 'BASE TABLE')

I also updated the php.ini file to allow the pgsql extensions:

 extension=pdo_pgsql
 extension=pgsql

and of course I also cleared the cache with php artisan optimize and php artisan config:clear

what else could I be missing so I can migrate this?

0 likes
5 replies
Sinnbeck's avatar

After enabling those you might need to restart the webserver or restart your computer

Use php -m to see if they are loaded

1 like
dru's avatar
Level 3

Hi @Sinnbeck thanks for your prompt reply, and according to the list, its not loaded. but it's strange, I already installed postgres, and also edited the php.ini file, and restarted apache and then the PC and still is not working.

is there a DLL to be installed or something?

the list:

bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imap
json
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@dru Any chance you have two php.ini files? One for apache and one for cli?

1 like
dru's avatar
Level 3

thanks @Sinnbeck, yes, that was the problem I had two php in xampp and the PHP ini from the xampp console only points to the older version.

Please or to participate in this conversation.