#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    155
    Rep Power
    13

    pg_connect() unable to connect to PostgreSQL server


    Hi all. This might seem like a php question by the title but it's answer lies within postgres.

    When I try to connect I get the following error:

    Warning: pg_connect() unable to connect to PostgreSQL server: Connection refused. Is the server running on localhost and accepting TCP/IP connections on port 5432?

    I'm quite new to having to administer postgresql so I've no idea how to check that, and haven't been able to find anything of much use online.

    Can anyone give any advice?

    Thanks in advance,
    Pablo
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    France
    Posts
    55
    Rep Power
    13

    Re: pg_connect() unable to connect to PostgreSQL server


    I see 3 possibilities to fix your problem :

    1 - Check the postmaster is launched with the -i option. It means it can get tcp/ip connections

    2 - Look into the pg_hba.conf file in the pgsql folder (/var/log/pgsql under redhat). This file manages access to the postmaster. The syntax is explained inside it.

    3 - If the postmaster is on the same system as apache I think u may connect it through unix sockets, not tcp/ip. BTW, what is your connection string?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    155
    Rep Power
    13
    Problem was within the pg_hba.conf file. Needed to add an entry for 127.0.0.1 and all was solved.

    Pablo

IMN logo majestic logo threadwatch logo seochat tools logo