Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqM8H-0002ie-9R for pgsql-sql@arkaria.postgresql.org; Wed, 13 Apr 2016 14:51:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aqM8G-0000Wd-Nk for pgsql-sql@arkaria.postgresql.org; Wed, 13 Apr 2016 14:51:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aqM8E-0000V1-SX for pgsql-sql@postgresql.org; Wed, 13 Apr 2016 14:51:03 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aqM86-0001L1-Oh for pgsql-sql@postgresql.org; Wed, 13 Apr 2016 14:51:02 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 25E92213CA for ; Wed, 13 Apr 2016 10:50:53 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 13 Apr 2016 10:50:53 -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=axg42rjqOXIICAQxdicsIVFeTZM=; b=oKOX15 bEKDocVHNAsttBjVCX6O/Hr/jXV2R20WJ9PsOtvQar3b+COI1W+zuYUxbAnLU2Dk +CACcef5Z1k505W1kJK4ldHzCxibhzIByUX8o2qz3gTXdRpWDX69OYreuNRGv3X8 PKiS2nyLQS1zMjs2vWHAo5nx13bpm1XCpqH4g= 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=axg42rjqOXIICAQ xdicsIVFeTZM=; b=WZGYEq06p2KPoiZ8qR1hblbEbWjpwNNaG+XzVnwWRFduwBf PK/q3zIIkIMwhd9AkVFHRLdHUlZANHihC3+lv9lJoemXzupsYhHUIpO88+2Ja1Fj dO0ovCNWI7Fks3z1lVYtmIyAtETxP91j8Utwhm9MRUNz225ucpr3f9j3Ct2o= X-Sasl-enc: c8ZDY66z7YrIaWdlwcuiX/KKR2UQsE3c4UPQvRpVZsLZ 1460559052 Received: from [192.168.1.2] (174-24-160-10.tukw.qwest.net [174.24.160.10]) by mail.messagingengine.com (Postfix) with ESMTPA id AC1846802BF; Wed, 13 Apr 2016 10:50:52 -0400 (EDT) Subject: Re: 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> <570D7D2C.8010404@aklaver.com> <1460503188702-5898337.post@n5.nabble.com> From: Adrian Klaver Message-ID: <570E5CCB.502@aklaver.com> Date: Wed, 13 Apr 2016 07:50:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1460503188702-5898337.post@n5.nabble.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) 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/12/2016 04:19 PM, Chris wrote: > 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 So is it possible to show the complete pg_hba.conf? > > 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. > > -- 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