Whenever I try to start my project the following error occurs.

django.db.utils.OperationalError: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

This is the status of postgres:

● postgresql.service - PostgreSQL RDBMS
  Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor preset: enabled)
  Active: inactive (dead)

And it will only work when I restart the service, how can I avoid restarting it every time I turn on my laptop could it be that the installation is wrong?

I'm using Ubuntu 18


The output you showed from systemctl status postgresql indicates that it is "disabled", meaning it will not start by default:

Loaded: loaded (/lib/systemd/system/postgresql.service; disabled;

Enable the service to let it start at boot:

sudo systemctl enable postgresql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.