1

In order to be able to connect to my postgresql database from another machine, I had to configure my postgresql.conf file like so:

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '10.14.4.4'                # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
port = 5432                             # (change requires restart)

I tried using 127.0.0.1 but that didn't work. Neither did "localhost". The only way I was able to do make this work is to use the actual IP address of the server. I checked to make sure in my "hosts" file, localhost was defined....

In any case, I am now able to connect from a different server by doing the following:

psql -U test test -h 10.14.4.4

But now I'm noticing that I cannot log on locally using the following syntax:

psql -U test test -h 127.0.0.1

The only way to log in locally is

psql -U test test

I tried to change my postgresql.conf file to use "*"... and that let's me log in remotely, but locally, i still cannot use 127.0.0.1 or "localhost" to connect.

How can I set this up so that both my remote logins and my local logins work?

1
  • Did you try a comma-separated list of address like the comment suggests? 'localhost,10.14.4.4'
    – Craig
    Nov 19, 2013 at 20:07

1 Answer 1

1

I had to edit my pg_hba.conf file:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                trust
#host    replication     postgres        127.0.0.1/32            trust
#host    replication     postgres        ::1/128                 trust
host    all             all             10.14.4.0/24             md5
host    replication     postgres        10.14.0.0/16              trust

I changed the methods from "trust" to "md5" and that's fixed my problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .