close

[Solved] django.db.utils.Operational Could not connect to server

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error django.db.utils.Operational Could not connect to server in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How django.db.utils.Operational Could not connect to server Error Occurs?

Today I get the following error django.db.utils.Operational Could not connect to server in python.

How To Solve django.db.utils.Operational Could not connect to server Error ?

  1. How To Solve django.db.utils.Operational Could not connect to server Error ?

    To Solve django.db.utils.Operational Could not connect to server Error In my case, all was set up well and Postgres had the right port, PostgreSQL was running normally, but the 5432 port was being shared with phppgadmin

  2. django.db.utils.Operational Could not connect to server

    To Solve django.db.utils.Operational Could not connect to server Error In my case, all was set up well and Postgres had the right port, PostgreSQL was running normally, but the 5432 port was being shared with phppgadmin

Solution 1

It can be some issues:

  1. PostgreSQL is not running. Check it with sudo service postgresql status
  2. Your PostgresSQl is not running on port 5432. You can check it typing sudo netstat -nl | grep postgres
  3. You have something wrong trying to connect to your db like the username, the password or the databasename. Check that they are what postgres ask for you to connect it and that is the db_name that you want to access to.
  4. Problems with postmaster.pid in postgres. It can happen because of a shutdown unproperly done. It makes to remind a pid alive that doesn’t allow your server start. To fix it you have to: * rm /usr/local/var/postgres/postmaster.pid * pg_resetxlog -f /usr/local/var/postgres After this it should run properly if you make the runserver of postgres

Solution 2

In my case, all was set up well and Postgres had the right port, PostgreSQL was running normally, but the 5432 port was being shared with phppgadmin, I could access the phppgadmin that gives me web access to Postgres database server, but my Django application was not working it would return Connection refused error. so I changed the port number on the phppgadmin config file (/etc/phppgadmin/config.inc.php) to 5433 from 5432 and all worked fine.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read