Welcome Guest, Not a member yet? Register   Sign In
Unable to connect to the database. (postgres)
#1

(This post was last modified: 09-04-2020, 07:56 AM by jreklund.)

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

Attached Files Thumbnail(s)
   
Reply
#2

(This post was last modified: 09-10-2020, 10:48 AM by Omar Crespo.)

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.
Reply
#3

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
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(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...
Reply
#5

(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. 
Reply
#6

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB