Posts

Showing posts from December, 2023

Allow Remote Connection to PostgreSQL / no pg_hba.conf entry for host ***.**.**.*

  When you install PostgreSQL, by default connection to the database using TCP/IP is not allowed. When you try to connect from a client to a remote PostgreSQL database using  psql  command, you might get a  psql: could not connect to server: Connection refused  error message. In the following example, from a client machine, we are trying to connect to a PostgreSQL database that is running on  66.249.75.34  server. As you see from the output, it clearly says that the remote PostgreSQL database is not accepting connection. # psql -U postgres -h 66.249.75.34 psql: could not connect to server: Connection refused Is the server running on host "66.249.75.34" and accepting TCP/IP connections on port 5432 ? To enable TCP/IP connection for PostgreSQL database, you need to follow the two steps mentioned below. 1. Modify  pg_hba.conf  to Add Client Authentication Record On the PostgreSQL database server, by default, you’ll notice the following records towards the end o