[Answered ]-How can I solve the issue: psql cannot connect to the server in Ubuntu?

0πŸ‘

βœ…

I solve the problem by editing the file postgresql.conf located in /etc/postgresql/14/main/postgresql.conf
Then I uncommented and edit the listen_addresses attribute to start listening to start listening to all available IP addresses: listen_addresses = '*'

In addition I edited the PostgreSQL access policy configuration file as follow:

vim /etc/postgresql/14/main/pg_hba.conf. 

Then I modified the file as follow:

host all all 0.0.0.0/0 md5

And now it is working fine. Thanks a lot @AdrianKlaver

1πŸ‘

Doing:

sudo systemctl status postgresql.service

just shows whether the status of the bootstrap process postgresql.service ran. This process is used to start the actual Postgres server or servers.

To see whether the actual servers are running do:

pg_lsclusters

This will show the status of the server(s).

Another option is to to use:

sudo systemctl status postgresql@<version>-main.service

where you replace <version> with the version number of the Postgres server.

πŸ‘€Adrian Klaver

Leave a comment