Django - OperationalError at /admin/login/

Hi there!

I have setup my django app and it is running perfectly fine. However, when i go to the admin/ i get a server Error(500). In debug, the error comes up as

OperationalError at /admin/login/. 
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"?

The server seems to be running fine as I can connect to it using psql. I have deleted and recreated my databases but the problem still persists.

What is it that I could be missing?

Thanks in advance.

That looks like you're trying to connect to a your Postgres instance through a local socket. The details for your Postgres instance are on your Databases page. In particular, be aware that you need to correctly use the host and port settings.

Hi Glenn. Thanks for the response. I am using the details exactly as on the Database page. I have discovered however that my problem is with the environment variables. It seems nothing is being read from there as hardcoding the values appears to work. I will try to rework the environment variables. If you can point me to a recommended approach, I would greatly appreciate it.

So I managed to solve the environment variables using instructions on this link.

How to set environment variables for your web apps


Excellent, glad you were able to work it out!