agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Adrian Klaver <adrian.klaver@aklaver.com>
To: Chris <cglenstark@apple.com>
To: pgsql-sql@postgresql.org
Subject: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host
Date: Tue, 12 Apr 2016 15:56:44 -0700
Message-ID: <570D7D2C.8010404@aklaver.com> (raw)
In-Reply-To: <1460413886714-5898099.post@n5.nabble.com>
References: <1460413886714-5898099.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
On 04/11/2016 03:31 PM, Chris wrote:
> Introduction:
>
> I am working on an application that connects to a postgres database using
> the libpq API. As a requirement the remote host uses SSL.
>
> The scenario involves two Mac computers. We also have two different users,
> each with their own account to access the database.
>
> On one computer, the application works fine and both users can connect to
> the database using SSL.
>
> On the other computer, both users fail to connect to a database and the “no
> pg_hba.cong entry for host …” error is returned from PQerrorMessage.
>
> All users can connect to the database on both computers using either psql,
> or pgAdmin.
>
> Code Syntax:
>
> Development is done on Mac with code written in Cocoa / Objectice-C, and C
> language.
>
> I am using the following include file:
>
> #include <libpq-fe.h>
>
> I create the connection string using the following format. Then
>
> NSString *connstr = [NSString stringWithFormat:@"sslmode='prefer' host='%@'
> port='%@' user='%@' password='%@' dbname='%@'", host, port, user, pass, db];
>
> const char *conninfo = [connstr cStringUsingEncoding:NSASCIIStringEncoding];
>
> PGconn *conn = PQconnectdb (conninfo);
>
> /*
> conninfo = "sslmode='prefer' host='host.domain.com' port='' user='username'
> password='password' dbname='database'"
> */
>
> if (PQstatus(conn) != CONNECTION_OK)
> {
> // no pg_hba.conf entry for host error occurs
> }
>
>
> Configuration Settings:
>
> pg_hba.conf contains
>
> hostssl all all 0.0.0.0/0 md5
>
>
> postgresql.conf contains
>
> ssl on on
> ssl_cert_file server.crt server.crt
> ssl_key_file server.key server.key
>
>
> Since I able to connect to both computers using psql and pgAdmin, I suspect
> the problem is with the connection within the Application. The connection
> string in the application is correct, and I verified the user name and
> password being passed properly.
Have you verified the other parameters, in particular the port. I am
suspicious of the port='' in the above. The error is pretty straight
forward, the correct host name is not being found in the the pg_hba.conf
file. That means either the host name is not specified correctly in
the file or you are connecting to a different cluster(port) then you
think are and are picking up a different pg_hba.conf.
>
>
>
> --
> View this message in context: http://postgresql.nabble.com/Connection-to-database-failed-FATAL-no-pg-hba-conf-entry-for-host-tp589...
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (6+ messages) latest in thread
Message-ID: <570D7D2C.8010404@aklaver.com>
Permalink: ../570D7D2C.8010404@aklaver.com/
Also on: postgresql.org/message-id/570D7D2C.8010404@aklaver.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: adrian.klaver@aklaver.com, cglenstark@apple.com
Subject: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host
In-Reply-To: <570D7D2C.8010404@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox