Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.

Sign up to join this community

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

unable to connect to server: connection failed: connection refused is the server running on that host accepting tcp/ip connections?

Ask Question

I have postgres 13.10 and PGAdmin4 7.1 installed on Ubuntu 22.04

In PGAdmin4 UI, I want to "add new server" with these configurations

postgres-local username postgres postgres hostanme / address 127.0.0.1 server group Servers

so I have run in my terminal

sudo -i -u postgres
ALTER USER postgres WITH PASSWORD 'postgres';

Then I login into PGAdmin4, try to add new server inserting the cofigurations above, but as I click on save I get this error

unable to connect to server: connection failed: connection refused is the server running on that host accepting tcp/ip connections?

What could be the problem?

What I already tried

I have checked that postgres is running correctly via sudo service postgresql status.

I have already tryed to

edit file /etc/postgresql/13/main/postgresql.conf uncommenting
listen_addresses = 'localhost'
and changing it into
listen_addresses = '*'

edit file /etc/postgresql/13/main/pg_hba.conf changing lines

# IPv4 local connections:
host    all             all             127.0.0.1/32               md5
# IPv4 local connections:
host    all             all             0.0.0.0/0               md5

restarting postgres

sudo service postgresql restart

But I had no success.

Have you made sure that postgres is running on that port?

sudo netstat -lntp | grep postgres

Have you made sure that the firewall is not blocking that port?

sudo ufw allow 5432
                Actually by running sudo netstat -lntp | grep postgres I found out postgres was runnng under port 5433. I was going to uninstall and reinstall all. Thanks!!
– Tms91
                May 6 at 21:29