0

I am running PostgreSQL 9.3 on ubuntu 14.04 LTS. It is the stock Postgres distribution available in apt. I found a bunch of threads in various forums that indicate that the correct way to allow remote psql connections to the database is to add the following line to /etc/postgresql/9.3/main/pg_hba.conf:

host    all             all       0.0.0.0/0             md5

And to set this in /etc/postgresql/9.3/main/postgresql.conf:

listen_addresses = '*'

then to restart the dbms ("sudo service postgresql restart")

I have done this and am still getting the following error when attempting to connect to this DB from another server:

psql -h <the db host> -p 5433 -d the_db the_user
$> Password for user the_user:  
$> (I enter the pw)
$> psql: FATAL:  password authentication failed for user "the_user"
$> FATAL:  password authentication failed for user "the_user"

Please note that the password is unambiguously correct as the following, executed on the DB's host machine, gets me in successfully:

$>  psql -h localhost -d the_db the_user
$> Password for user the_user: 
$> (I enter the exact same pw as above)
$> psql (9.3.5, server 9.1.13)
$> Type "help" for help.
$> 
<the psql shell session begins>

I am at a loss to see where I am going wrong here as the configuration seems to be correct, the password is correct, and the host machine does seem to be accepting the remote connection (for the prompt) and just failing at the point of authentication. Please let me know if you've ideas about how to get this working. Thanks.

1
  • In addition to giomasce's point, also make sure you reloaded PostgreSQL after changing pg_hba.conf. Commented Oct 13, 2014 at 1:27

1 Answer 1

2

In the first session you are using port 5433, in the second one you are using default 5432. You probably have more than one cluster installed (they probably came with different version of the PostgreSQL package). I recommend you to drop the clusters you do not use with pg_dropcluster and check that you are connecting to the correct one.

(remember to double check before dropping things, if there are databases with worthy information inside)

1
  • To follow up on this: indeed you were correct and I was connecting to the wrong postgres instance. Running "sudo pg_lsclusters" showed that I was running 2 versions of postgres (9.1 and 9.3) side by side on 5433 and 5432. I migrated all my data onto 9.3 (just w/ a pg_dumpall) and uninstalled 9.1. I am now able to connect to my 9.3 install according to the rules in the pg_hba.conf for that install
    – Nick Z
    Commented Oct 18, 2014 at 19:04

You must log in to answer this question.

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