I keep running into the problem of not being able to connect to the database:
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 "/opt/bitnami/postgresql/.s.PGSQL.5432/.s.PGSQL.5432"?
its my list of databases:
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
and its the postgres config section of settings.py
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'HOST': '/opt/bitnami/postgresql/.s.PGSQL.5432',
'PORT': '5432',
'USER': 'postgres',
'PASSWORD': 'mypass'
}
}
I also tried answers to these two questions
- Can't connect to Postgres database with Bitnami Django stack
- Can't connect the postgreSQL with psycopg2 but none of them helped.
here is pip list
:
psycopg2-binary==2.8.6
my debug mode is false:
DEBUG = False
and in allowed hosts I have my private IP:
ALLOWED_HOSTS = ['XXX.XXX.XXX.XXX']