1👍
You can connect in 2 different ways to PostgreSQL:
- Unix sockets. They are special files on your filesystem that process can write into and read from.
- TCP sockets, which main purpose is to allow inter-machine communications on top of the Internet Protocol, but that can very well be used to connect 2 processes on the same machine.
The error message you’re getting tells you that Django attempted method one, looking for a special file representing a Unix socket, but didn’t succeed. It’s very likely that your PostgreSQL instance listens on TCP sockets instead of Unix sockets. To confirm this, try to connect to PostgreSQL using the psql
command line client like this:
psql -h localhost -U user databse_name
If you’re successful, then you can configure Django to connect to localhost via TCP sockets by setting the HOST
key in your settings.py
file:
DATABASES = {
'default': {
[...]
'HOST': 'localhost',
[...]
}
}
Source:stackexchange.com