CodeIgniter Forums
Unable to connect to the database. (postgres) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Unable to connect to the database. (postgres) (/showthread.php?tid=77463)



Unable to connect to the database. (postgres) - postgres - 09-03-2020

Dear Friends,
I try to do your code with postgres. But when I click upload button i got error as "CodeIgniter\Database\Exceptions\DatabaseException #8 Unable to connect to the database."

My connection details on localhost is:

PHP Code:
public $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'postgres',
'password' => '123',
'database' => 'demo',
'DBDriver' => 'Postgre',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 5432,
]; 

Please advise .. I am new in CI 4.0.4

I run the code using spark (php spark serve)

Waiting fast reply ...
Thanks
Anes P A


RE: Unable to connect to the database. (postgres) - Omar Crespo - 09-09-2020

Check if the name of the db Driver, table, user and password are correct.

Please post the error message in order to see what's wrong.


RE: Unable to connect to the database. (postgres) - InsiteFX - 09-10-2020

If you run it using spark it most likely has a port number also

So it would be 'hostname' = 'localhost:8080' or something like that.

If I run it on my system it is http://localhost:8080


RE: Unable to connect to the database. (postgres) - postgres - 09-11-2020

(09-10-2020, 11:28 AM)InsiteFX Wrote: If you run it using spark it most likely has a port number also

So it would be 'hostname' = 'localhost:8080' or something like that.

If I run it on my system it is http://localhost:8080
I added that 8080 in localhost as

Quote:public $default = [
'DSN'      => 'pgsql:host=localhost;port=5432;dbname=demo;user=postgres;password=123',
'hostname' => 'pgsql:host=localhost:8080;dbname=demo',
'username' => 'postgres',
'password' => '123',
'database' => 'demo',
'DBDriver' => 'Postgre',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug'  => (ENVIRONMENT !== 'production'),
'cacheOn'  => false,
'cacheDir' => '',
'charset'  => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre'  => '',
'encrypt'  => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port'    => 5432,
];




Still the same Error...



RE: Unable to connect to the database. (postgres) - postgres - 09-11-2020

(09-09-2020, 06:35 PM)Omar Crespo Wrote: Check if the name of the db Driver, table, user and password are correct.

Please post the error message in order to see what's wrong.
all details are correct...
Got error as

Quote:odeIgniter\Database\Exceptions\DatabaseException #8

Unable to connect to the database. 



RE: Unable to connect to the database. (postgres) - InsiteFX - 09-12-2020

Did you check to see what your port number was when you started the spark serve?

It shows on screen when you start it, yours maybe different from mine.