0
$dbconn = pg_connect("host=localhost   dbname=mydbname   user=myuser    password=mypass") or die(pg_last_error());

returns Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "::1 ...",

What I must do?

P.S. In file php.ini modul extension php_pgsql.dll is enabled

5
  • What does your pg_hba.conf file contain? Commented Apr 18, 2013 at 13:50
  • I dont know, this is remote server. Commented Apr 18, 2013 at 13:52
  • 2
    How can you use host=localhost then? Commented Apr 18, 2013 at 13:54
  • When use mysql (on remote server), as host value we can use host=localhost right? In postgresql this can not do? Commented Apr 18, 2013 at 13:58
  • 2
    If it's a remote server you can't be using host=localhost, no matter what database software you're using. (Unless you have an extremely oddly configured server!) Localhost means the server you are running your script on. Commented Apr 18, 2013 at 15:04

1 Answer 1

2

This or this would've helped you determine the nature of the problem.

It looks like you're trying to connect over IPv6 (hence ::1) and the host's pg_hba.conf doesn't have a rule allowing you to connect from the IPv6 loopback address (::1) as user myuser to database mypass.

I suspect the server is misconfigured; to work around it try specifying the host as 127.0.0.1 (the IPv4 loopback address) instead of localhost, or just omit the host= completely to use unix domain sockets if PHP supports that.

Your statement "When use mysql (on remote server), as host value we can use host=localhost right?" is completely nonsensical for both MySQL and PostgreSQL. If it's a remote server then it is by definition not on localhost. At a wild guess I think you might be trying to say that the server is remote in the sense that it's not the computer you are working on, but it's local to the program you are running because you are running the program on the remote server (by editing it on the remote server, uploading the program text over FTP, or whatever).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.