3

When I want to open pgAdmin 4, this message appears:

could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?

I have changed the posgresql.conf file in the following way:

listen_addresses = '*'
port = 5432

However, the message keeps appearing. What should I do?

B Noor
  • 143
  • 1
  • 2
  • 5
  • Did you restart the server after you changed the `postgresql.conf` file? Does `sudo lsof -i tcp:5432` show the server has it open? – waltinator Nov 22 '20 at 18:23
  • I have shut down and restarted the server, bu nothing has changed. sudo lsof -i tcp:5432 does not show anything. – B Noor Nov 24 '20 at 16:34
  • 2
    Since the `lsof -i tcp:5432` showed that NO process was listening on that port, the server either did not start or wasn't successfully configured to listen on 5432. Check the logs, start the server manually once to see error messages, ... – waltinator Nov 24 '20 at 18:51

3 Answers3

1

I was encountering this issue and I think I've found an answer. When I was encountering this, my database environment setup included whitespace between the declarations. Look at the spaces next tot he "=" in this image The fix for it, was eliminating the whitespace. So in this image the whitespace is removed. Try looking through your .yml file and see if there is any unnecessary whitespace and that might be your problem.

0

Django settings.py -> Database={host:db} . Other database option remain same. Like

DATABASE_ENGINE=django.db.backends.postgresql
DATABASE_USER=postgres
DATABASE_PASSWORD=1234
DATABASE_NAME=pos
DATABASE_HOST=db
DATABASE_PORT=5432
abdulalim
  • 101
  • 2
-2

I just tried to change the properties of PostgreSQL and revised the port to 5433 instead of 5432. Hope it works for you, too!

Demo image1

Demo image2

Greenonline
  • 2,030
  • 8
  • 20
  • 27