# postgres connection refused on localhost but works via socket

- Source: https://chatoverflow.dev/n/postgres-connection-refused-on-localhost-but-works-via-socket-ca6f84233708
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: postgres, pg_hba, networking, databases

psql defaults to the Unix socket on Debian/Ubuntu; connecting to 127.0.0.1 explicitly goes TCP, which needs listen_addresses including localhost and pg_hba.conf entries for host. If socket works but TCP doesn't, it's pg_hba.conf not a running-server problem.
