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 1l7faf-0005xe-91 for pgsql-general@arkaria.postgresql.org; Thu, 04 Feb 2021 14:26:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l7fae-0000hG-1T for pgsql-general@arkaria.postgresql.org; Thu, 04 Feb 2021 14:26:36 +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 1l7fad-0000h9-Nm for pgsql-general@lists.postgresql.org; Thu, 04 Feb 2021 14:26:35 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7faX-0007Iq-I5 for pgsql-general@lists.postgresql.org; Thu, 04 Feb 2021 14:26:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z31uasjTCUYZuXBHpq2hhPJgBXCo41pd7hIqQwXMXls=; b=ZTt/2z9VPIhCbbhGrMHsD2XN0c F5lOIa+Z+umPo1jCp2+la5Y2XItwP6y6l/J3Zn+x7jlVcMEa74X1bbY5f5xNN37eQDe3SfYDnubf6 uwnvZ0JiS2OkTXNUOovIKLhTOUu7iu20uiz/zRZyfFF8f58Y2AW3rG5kvHr0wrf1KXwY=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1l7faV-0007CD-R8; Thu, 04 Feb 2021 15:26:28 +0100 Date: Thu, 4 Feb 2021 15:26:27 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Joao Miguel Ferreira Cc: pgsql-general Subject: Re: cant connect to localhost:5432 (but unix socket ok) Message-ID: <20210204142627.GA22609@depesz.com> Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Feb 04, 2021 at 02:20:10PM +0000, Joao Miguel Ferreira wrote: > My database is not listening on TCP/localhost, desptite it is listening on the unix socket. How can I investigate this? > I could have done something that is out of my understanding because I have been loading some big pg_dumpall files that might contain > administrative changes that I am not fully aware of. There are couple of potential issues: 1. it might listen on different port than 5432. What does "show port;" show in psql? 2. it could be that there is a firewall (weird, but possible) 3. it could be that it's listening on another address(es) than 127.0.0.1 / ::1 - what is output of "show listen_addresses;"? 4. Verify that it really does listen on something. As root run: ss -ntlp | grep postgres depesz > Here are some details about the connection issue: > root@deb10tp:~# id > uid=0(root) gid=0(root) groups=0(root) > root@deb10tp:~# su postgres > postgres@deb10tp:/root$ id > uid=116(postgres) gid=126(postgres) groups=126(postgres),125(ssl-cert) > postgres@deb10tp:/root$ cd / > postgres@deb10tp:/$ psql -h localhost > psql: could not connect to server: Connection refused > Is the server running on host "localhost" (::1) and accepting > TCP/IP connections on port 5432? > could not connect to server: Connection refused > Is the server running on host "localhost" (127.0.0.1) and accepting > TCP/IP connections on port 5432? > postgres@deb10tp:/$ psql > psql (11.9 (Debian 11.9-0+deb10u1)) > Type "help" for help. > postgres=# > Thank you > Joao