django.db.utils.OperationalError Could not connect to server

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

Help in Mac OSX: How to start PostgreSQL server on Mac OS X?


Try killing all postgres processes. Im on a MAC and this solution that I've found on ubuntus forum really works.

https://askubuntu.com/questions/547434/how-to-nicely-stop-all-postgres-processes enter image description here


For Windows

Go to search bar and just write "Open psql" and hit Enter.

Once screen is opened, rerun django project.