Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aq7G8-000193-6w for pgsql-sql@arkaria.postgresql.org; Tue, 12 Apr 2016 22:58:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aq7G7-0004WC-Pm for pgsql-sql@arkaria.postgresql.org; Tue, 12 Apr 2016 22:58:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aq7F9-0002vx-R3 for pgsql-sql@postgresql.org; Tue, 12 Apr 2016 22:57:12 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aq7F6-0002n4-IZ for pgsql-sql@postgresql.org; Tue, 12 Apr 2016 22:57:10 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id CB0CF21F53 for ; Tue, 12 Apr 2016 18:56:45 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 12 Apr 2016 18:56:45 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=9X05UMZcxtcjIGjpNU2rIPz5ZlU=; b=N9YsPm gTNdOx3HTR+U17/Xz6g75F5d3g5NYfsYNhIRiW0QfZOZAgI6mYxKr/nvu8BxYKKE 9lK1/Kxi8fXSKIt4wssCmLutjJ/HWMBxNETdrvWNNcoM2xXB4n+kLYkTK0bpLiYA mty2KE0ZnamvcpN0vPdOpBnZkD3FI7ljBQ/GI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=9X05UMZcxtcjIGj pNU2rIPz5ZlU=; b=uvCc044293sf3D6usijmiBvDKeGTETOpA3NqSdtCfl20rqg NMcbxEZs2kf6z0bs4XKDQS1l9WbpJGHSHYDFj6tT3oDi5YPhMzu8NHc5JtqBmgdo rtephvoQnR3G7Jq/sQ9Ye5pEMpWgW4w0R4QwGzBik8rp/P/rAIw/FqKGTXQ0= X-Sasl-enc: CDKNcxfgQ+jsx0uXd4lN8RobAre0XVtWICFk3xtHVyyh 1460501805 Received: from killi.site (c-73-225-242-52.hsd1.wa.comcast.net [73.225.242.52]) by mail.messagingengine.com (Postfix) with ESMTPA id 51222C00013; Tue, 12 Apr 2016 18:56:45 -0400 (EDT) Subject: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host To: Chris , pgsql-sql@postgresql.org References: <1460413886714-5898099.post@n5.nabble.com> From: Adrian Klaver Message-ID: <570D7D2C.8010404@aklaver.com> Date: Tue, 12 Apr 2016 15:56:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1460413886714-5898099.post@n5.nabble.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.28 (deferred) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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 > > 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-tp5898099.html > 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