Testing database credentials Craft 3 Setup
This might be the problem with the pgsql driver.
You need to install and activate postgresql extension in PHP
You can use below command to install it.
[sudo] apt-get install php-pgsql

For activating it, uncomment pgsql and pdo-pgsql extensions in etc/php/$PHP_VERSION/apache2/php.ini file.
After all this you need to restart you apache server and the try to connect again.