Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqLpU-0001rL-Sb for pgsql-sql@arkaria.postgresql.org; Wed, 13 Apr 2016 14:31:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aqLpU-0002ph-4e for pgsql-sql@arkaria.postgresql.org; Wed, 13 Apr 2016 14:31:40 +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 1aq7b9-0005J2-Rh for pgsql-sql@postgresql.org; Tue, 12 Apr 2016 23:19:55 +0000 Received: from mbob.nabble.com ([162.253.133.15]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aq7b4-0003FC-RL for pgsql-sql@postgresql.org; Tue, 12 Apr 2016 23:19:52 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id 222DB25154ED for ; Tue, 12 Apr 2016 16:07:07 -0700 (PDT) Date: Tue, 12 Apr 2016 16:19:48 -0700 (MST) From: Chris To: pgsql-sql@postgresql.org Message-ID: <1460503188702-5898337.post@n5.nabble.com> In-Reply-To: <570D7D2C.8010404@aklaver.com> References: <1460413886714-5898099.post@n5.nabble.com> <570D7D2C.8010404@aklaver.com> Subject: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Thanks for your reply Adrian. I thought about the port. The server name is correct, and I provided the default port 5432 in place of the empty string. And it still did not work. We are using the default port settings for both SSL and non-SSL connections. I also tried using the PQconnectdbParams (see below) in place of PQconnectdb. Using exactly the same code as in the Open Source with few minor modifications. Connecting using this method still fails with the following error message... Connection to database failed: FATAL: no pg_hba.conf entry for host "12.224.126.19", user "james", database "database", SSL off Now I am trying to figure out why psql works with the code below, but the Application that I am creating does not. I checked that the encoding NSASCIIStringEncoding is converted properly, I even hard coded the parameters to no avail. Would there be any compiler setting I need to set in XCode? I am building on Yosemite. The application is connecting properly on several Mac computers running both Yosemite and El Capitan. We only have three computers where the application fails to connect, each being either Yosemite or El Capitan. Each have some type of SSL network connection, otherwise spql would not succeed. Strange part about this problem is that not every computer is having this connection issue, and the computers that are failing, work perfectly fine with psql and pgAdmin. bool notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout))); #define PARAMS_ARRAY_SIZE 7 const char **keywords = malloc(PARAMS_ARRAY_SIZE * sizeof(*keywords)); const char **values = malloc(PARAMS_ARRAY_SIZE * sizeof(*values)); keywords[0] = "host"; values[0] = [host cStringUsingEncoding:NSASCIIStringEncoding]; keywords[1] = "port"; if ([port isEqualToString:@""]) { values[1] = "5432"; } else{ values[1] = [port cStringUsingEncoding:NSASCIIStringEncoding]; } keywords[2] = "user"; values[2] = [user cStringUsingEncoding:NSASCIIStringEncoding]; keywords[3] = "password"; values[3] = [pass cStringUsingEncoding:NSASCIIStringEncoding]; keywords[4] = "dbname"; values[4] = [db cStringUsingEncoding:NSASCIIStringEncoding]; keywords[5] = "client_encoding"; values[5] = (notty || getenv("PGCLIENTENCODING")) ? NULL : "auto"; keywords[6] = NULL; values[6] = NULL; //new_pass = false; conn = PQconnectdbParams(keywords, values, true); free(keywords); free(values); -- View this message in context: http://postgresql.nabble.com/Connection-to-database-failed-FATAL-no-pg-hba-conf-entry-for-host-tp5898099p5898337.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql