Postgresql Cannot Connect Using 127.0.0.1

Hi, I am using Yii with PostgreSQL for the first time and I have a little difficulties in setting up the database on the hosting.

This is my config for the db :




'db'=>array(

        'connectionString' => 'pgsql:host=localhost;port=5432;dbname=k39xxxxx_mwntest', 

	'emulatePrepare' => true,

	'username' => 'k39xxxxx_mwnuser', 

	'password' => 'mypassword', 

        'tablePrefix' => '',

	'charset' => 'utf8',

        'enableProfiling' => true,

        'enableParamLogging' => true

),       



And it gets the error :

"CDbConnection failed to open the DB connection: SQLSTATE[08006] [7] FATAL: no pg_hba.conf entry for host "::1", user "k39xxxxx_owner", database "k3924916_dev", SSL off"

But when I try to connect manually it success. Below is the code when I try to connect manually :




$dbcon2 = new PDO("pgsql:dbname=k39xxxxx_mwntest;host=127.0.0.1", 'k39xxxxx_mwnuser', 'mypassword' );

if ($dbcon2) {

    echo "Success!";

} else {

    echo "Fail : ".mysql_error();

}



If I change "127.0.0.1" above to localhost, then it gets the same error :

"no pg_hba.conf entry for host "::1", user "k39xxxxx_owner", database "k3924916_dev", SSL off

So it seems like I have to use "127.0.0.1" to connect to the db. When I ask the hosting support, they say that the connection must use "127.0.0.1" instead of "localhost". But if I replace my config/main using 127.0.0.1, then it gets error :

"Driver does not support this function: driver does not support setting attributes"

What must I do ? Please help… Thanks

[color="#1C2837"][size="2"]Note that "::1" is the IPv6 localhost address, 127.0.0.1 is the IPv4 localhost address.[/size][/color]

[size="2"] [/size]

[size=“2”][color="#1c2837"]If you don’t need IPv6 you can disable it and then it will work.

[/color][/size]

[color="#1C2837"] [/color]

Thank so much for the reply. It seems like the driver does not support ‘emulatePrepare’ attribute so I erase it and now it works well :D