简体   繁体   中英

Zend framework - connection to postgresql

I encountered troubles when trying to connect to postgresql database within Zend framework application. In my application.ini I use

resources.db.adapter = PDO_PGSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = testtest
resources.db.params.dbname = testdb

But when I run the application, I got an error message Message: SQLSTATE[08006] [7] could not create socket: Address family not supported by protocol.

Could you please tell me what can be wrong?

Zend version 1.12.3., PostgreSQL version 9.0.7, PHP version 5.3.5.

Thanks, Marek .

localhost on your machine is (most likely) resolving to the IPv6 address of localhost ( ::1 ), but since the protocol/module used does not support IPv6 connections, your connection fails.

You could either;

  • Use 127.0.0.1 as a host instead, that will force a connection to the IPv4 localhost.

  • Remove the host line completely, that will force a connection via UNIX sockets.

I had similar problem:

PDOException: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? in lock_may_be_available() (line of /app/ctr/ctr web/drupal/includes/lock.inc).

The problem was caused because of a full disk. and PostgreSQL DB blocked/froze. Making some free space and restarting of PostgreSQL DB resolved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM