Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jyHOD-000252-LF for pgsql-general@arkaria.postgresql.org; Wed, 22 Jul 2020 16:14:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jyHOC-0002DB-AJ for pgsql-general@arkaria.postgresql.org; Wed, 22 Jul 2020 16:14:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jyHOA-0002D3-CD for pgsql-general@lists.postgresql.org; Wed, 22 Jul 2020 16:14:40 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jyHO3-0001Eh-A6 for pgsql-general@lists.postgresql.org; Wed, 22 Jul 2020 16:14:37 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7042A1135; Wed, 22 Jul 2020 12:14:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 22 Jul 2020 12:14:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=a nWVJCIbEWRjN2SsgTsDTRq4GVsNmRxPlp2WM9wo6MA=; b=i/k/i1h6/8E5FkDEf 5f17gT7L23l9HqMBwtU8djD1itKS+MJpwEJS+bg4QVwii5PIr28HW6/78ZjlZz5n yBwc89c9ciYc9+lMjGeMtjdi4F2W/c6fm0vD36EpwD//BGDByGEprGBYuhXVkHBg NEPsV2puRM2xz7qBjtIhTW1/ZbbdVY0IR5WGmYjJTY8SkTSVmErYsYsz51pTITha dXNOL8/8tK0idKEtjsedW55oiuUnMCisipkHVQpK/bLtQBQQkw3Dkupg9KNXwh+Y PsGWMemdpJIyEP1CWGKP9ORzCtGk12w7s2dHGwVsUtaMNaUReXbh0fi5DiiwsIgi X/B2w== DKIM-Signature: v=1; a=rsa-sha256; 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-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=anWVJCIbEWRjN2SsgTsDTRq4GVsNmRxPlp2WM9wo6 MA=; b=Wh+DV/a32zd+f6WDLY7/Y10QVrwrNRtWichu9zJHq0fY00rMMl5oeAfsN DyHBnUgCIWK33U7oySnOy3Xo3GhIfhFYq/qpz42qYnWFcztfc4u45XZnXW7emstm NZr2FdGvWfnXCfZ0mpaGwQGL2FJFNjpE/rUcRPqEkqJ1tc+FgonYxQXpzHi+wde2 N26yQ0PkbfYyaEJbN3F7YK77ffRtzX9fxYYjtawNSzU7AZXge2oJduW/L8M2/93w n0tlFyrHR+tNtnxFRxstNTCG3wG1KahJ2n3drwUqQ+JYGIKU1RnpapPaUU2Uy+u7 2mLRuML2sgD6oeWhqMKy5sKpA1x0A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrgeelgdelhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekre dttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeevveefveefue egffekkefhgeeiueffgfetueejvdfghfeujeejhfekjeelgedtgeenucfkphephedtrddu leejrdektddrvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from ranger.suse (50-197-80-2-static.hfc.comcastbusiness.net [50.197.80.2]) by mail.messagingengine.com (Postfix) with ESMTPA id 4D56130600A3; Wed, 22 Jul 2020 12:14:28 -0400 (EDT) Subject: Re: Problem with pg_service.conf To: =?UTF-8?Q?Micha=c5=82_Lis?= , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: Date: Wed, 22 Jul 2020 09:14:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/21/20 2:35 PM, MichaƂ Lis wrote: > Hello, > > I can't connect to a database via service defined in pg_service.conf > file from remote machine. > > Connection from local machine using this service definition works fine. > > I tested it on PostgreSQL 9.4 and 9.6. The other problem is with the > localization of the pg_service.conf file. > > Reading internet solutions, I found, that this file may be placed in > global configuration folder. > > In my case it is D:\PostgreSQLx86\9.6\etc (the SYSCONFDIR variable > displayed by pg_config.exe). > > Placing the file into this folder does not work. I had to define the > global system variable PGSERVICEFILE = > D:\PostgreSQLx86\9.6\etc\pg_service.conf. > > After that the connection to database via service began work, but only > on local machine. > > To reproduce problem: > > 1. Create pg_service.conf file like this: > > [test4] > host=192.168.1.2 > port=5433 > dbname=test > user=postgres > password=abcd > > 2. Save this file in a directory, in my case it was > D:\PostgreSQLx86\9.6\etc\pg_service.conf > (line ends in Linux style by NotePad++) > > 3. Set the global system variable: > PGSERVICEFILE =D:\PostgreSQLx86\9.6\etc\pg_service.conf > > 4. Restart computer to take effects for setting PGSERVICEFILE > > 5. Open PGAdmin 3 or 4 no matter which. > > 6. Add and Set database connection > - Name: test > - Host: 192.168.1.2 > - Port: 0 > - Service: test4 > - User: > - Password: > > On the local machine the connection will be established but on remote > machine the error: > > "Definition of service "test4" not found" > > will be raised > > Connection from remote machine to server by host, port, user and > password works fine. Where is the server located? Are you on remote machine when you try to use the service file? If so, that is not going to work as the remote machine will not have access to the local environment. > > PostgreSQL version: 9.6.11 and 9.4 > Operating system: Windows 7 x64 Pro/Ultimate > > Regards > Michal > > > > > -- Adrian Klaver adrian.klaver@aklaver.com