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 1mzgLy-0002uV-59 for pgsql-general@arkaria.postgresql.org; Tue, 21 Dec 2021 14:42:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mzgLv-0002nW-MZ for pgsql-general@arkaria.postgresql.org; Tue, 21 Dec 2021 14:42:55 +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 1mzgLv-0002nN-CF for pgsql-general@lists.postgresql.org; Tue, 21 Dec 2021 14:42:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mzgLo-00060x-Rz for pgsql-general@lists.postgresql.org; Tue, 21 Dec 2021 14:42:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1BLEgkh42754441; Tue, 21 Dec 2021 09:42:46 -0500 From: Tom Lane To: shing dong cc: pgsql-general@lists.postgresql.org Subject: Re: How to confirm the pg_hba.conf service is correctly working In-reply-to: References: Comments: In-reply-to shing dong message dated "Tue, 21 Dec 2021 17:18:22 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2754439.1640097766.1@sss.pgh.pa.us> Date: Tue, 21 Dec 2021 09:42:46 -0500 Message-ID: <2754440.1640097766@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk shing dong writes: > 1. The rules in pg_hba.conf are almost invalid > 2. pg_hba.conf is only useful for METHOD = trust > 3. check SHOW hba_file; the file location is correct > 4. select * from pg_hba_file_rules; checked is correct > 5.DB version : PostgreSQL 10.19 on x86_64-pc-linux-gnu, compiled by gcc > (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit > Even if you delete the text in pg_hba.conf > Keep only > host VJ VJ_USER 10.10.10.1/32 md5 > After pg_ctl reload and Restart DB , any ip, user still can log in to DB It's hard to say where your mistake is, but probably the first thing to check is whether you're really restarting the postmaster. I'm wondering in particular if there's more than one PG instance on the machine and you're reconfiguring or restarting the wrong one. Other than that, retrace your steps carefully, because at least one of the above statements must be wrong. (I guess if you were feeling *really* paranoid, you could wonder whether somebody replaced your postmaster executable with a hacked version that doesn't apply any pg_hba checks. But pilot error seems like a far more probable explanation.) regards, tom lane