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 1kiYaf-0004DJ-IN for pgsql-general@arkaria.postgresql.org; Fri, 27 Nov 2020 07:54:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kiYae-0001Bd-Gl for pgsql-general@arkaria.postgresql.org; Fri, 27 Nov 2020 07:54:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kiYae-0001BW-98 for pgsql-general@lists.postgresql.org; Fri, 27 Nov 2020 07:54:48 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kiYac-0006Cs-GC for pgsql-general@lists.postgresql.org; Fri, 27 Nov 2020 07:54:47 +0000 Received: by mail-ej1-x62c.google.com with SMTP id f9so4094979ejw.4 for ; Thu, 26 Nov 2020 23:54:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=FWPLpIxIwxkRTLr8kbec7i/o2Xk9oagIxpjej+ORg3s=; b=aKO+yOhBlDzMeZXmPAne7sRf+l4pMRaQKYwKE2ltru+Lee6/sMdWB0hXeNVgG9ngnl uvGyTWaIFmrrhf3o5JUnOrAjyaMV1cod2X05ojppAy4UJHkAP/2qd9Qg8zsUanaseEME S+qahJUGCleybLSr+Qb+bvObfdkADQQuNPKvLXU/mcKsz0HUYXiUYoAcaXgdIZdhMFuf EqLPG+hN1ghQ7r33g3G1QgAWtVDV6nPMYZvLvYl2fhMo2wHNY0IlWDsnMbRVe5NWwvA5 RMTcIR/WkMumGDfc2z0ELoKTKkd2tA1/W6dsekDCg8AtrydErRXG7bQPdUZrTGyDom0R s4Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=FWPLpIxIwxkRTLr8kbec7i/o2Xk9oagIxpjej+ORg3s=; b=C1ettaBuewSjViW50x0sTRbxWdum4phMJFwGO3g+RPhFGyP2pYxa8ufWf3td4aeK+8 OinRcVP3HYWNc1Yc/pYDMP0/REt/j+Cm9mkFM3tBEdTqAXHdu3zJTqqWiPjC/A5FvsrR AdbZJ47hna5GhL27lqxVZBL4n4a5uWj1FE9w8t9jUozzT/XiMKcVCD8HnTNS425np0Hd Ab6eVu9ZKuuKli+A1tPUWjFuG6DhGKl6qkLz3+ZWXkMJh+AHwlQjt7yKCnJsJGAYQIMW L798gAQkLMyksDG9pjml35jbvNz1uZHY69m7yeAU2uR2G3ShlWn6JIs5aE510oMpwIcB wayw== X-Gm-Message-State: AOAM5335PBNl1b8/HlXE1lDXvIpG7u/YUtZyJyqK0guAj1c8KA7Unv/O bOUh6MsBF6kI4D5LzvFfOSy2jMx3grAQN1dw X-Google-Smtp-Source: ABdhPJwVMcLb7AwjYuzgg1Pjxu+8nv2Z19FnOeqvgA+fpq/FscmoicmcjbHLXaIMrwRrSiJdS3wl/Q== X-Received: by 2002:a17:906:d1c3:: with SMTP id bs3mr6181007ejb.306.1606463685169; Thu, 26 Nov 2020 23:54:45 -0800 (PST) Received: from localhost.localdomain (178-190-168-149.adsl.highway.telekom.at. [178.190.168.149]) by smtp.gmail.com with ESMTPSA id p91sm4533595edp.9.2020.11.26.23.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 23:54:44 -0800 (PST) Message-ID: <5a5ca12d399ce798d027575f1271e831a482e9be.camel@cybertec.at> Subject: Re: How to debug authentication issues in Postgres From: Laurenz Albe To: Hemil Ruparel , "pgsql-generallists.postgresql.org" Date: Fri, 27 Nov 2020 08:54:44 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 2020-11-27 at 12:44 +0530, Hemil Ruparel wrote: > I have a remote database which I can connect to using psql command line tool as well as PgAdmin4. But I would really like to use DataGrip. But whenever I try to connect, it gives me fatal: password > authentication failed and prompts me for another password. I raised an issue in DataGrip and I was told there is an issue in my database configuration. > > Here is my pg_hba.conf: > ``` > # TYPE DATABASE USER ADDRESS METHOD > > # "local" is for Unix domain socket connections only > local all all peer > # IPv4 local connections: > host all all 127.0.0.1/32 scram-sha-256 > # IPv4 connections from internet > host database user 0.0.0.0/0 scram-sha-256 > host database user 0.0.0.0/0 md5 > host database user 0.0.0.0/0 password > # IPv6 local connections: > host all all ::1/128 scram-sha-256 > # IPv6 connections from internet: > host database user ::0/0 scram-sha-256 > host database user ::0/0 md5 > host database user ::0/0 password > # Allow replication connections from localhost, by a user with the > # replication privilege. > local replication all > ``` > > Since I know a Java and I know Idea uses java, so I wrote this small snippet to try to connect to my server using JDBC: > ```java > public class Test { > public static void main(String[] args) throws SQLException { > Connection connection = DriverManager.getConnection( > "jdbc:postgresql://url/database", > "user", > "password" > ); > > try (connection) { > Statement statement = connection.createStatement(); > statement.execute("select version()"); > } > } > } > ``` > And it failed with the same error You should consult the PostgreSQL log file. For one, the last line "local replication all" is syntactically wrong, which would lead to an error message in the log and cause the file not to take effect. It will also prevent PostgreSQL from starting if you restart it. The second reason to look into the log file (once you have fixed pg_hba.conf) is that it will give you more details to error message. The client gets less information, because such information could be useful to an attacker. I'd expect that you get at least the line in pg_hba.conf that was used, which will ease debugging for you. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com