Похожие чаты

This is my configues: https://gist.github.com/farzinh/b50312ca0523fb37ec846251a7671cb3 and here is docker-compose logs that shows

error:

....
django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Host is unreachable
Is the server running on host "db" (192.168.96.2) and accepting
TCP/IP connections on port 5432?

I checked every and each solution that I could found, but none of them works and I still have this error

7 ответов

5 просмотров

you're not exposing the postgres port

Farzin- Автор вопроса
Sathya Bhat
you're not exposing the postgres port

I had: ports: - "5432:5432" but it did't worked

Farzin- Автор вопроса
Sathya Bhat
you're not exposing the postgres port

I just exposed ports like this: ports: - "5432:5432" still same problem

Farzin
I just exposed ports like this: ports: - "5432:...

what returns on sudo service postgresql status sudo lsof -nP | grep LISTEN ? ——— have you run ? docker-compose up -d db docker-compose up -d web ——— Be aware, sometimes it's requires to set HOST as 127.0.0.1 in settings.py instead of "db": DATABASES = { 'default': { (...) 'HOST': '127.0.0.1', (...) } }

Farzin
I had: ports: - "5432:5432" but it did't worke...

docker-compose.yml version: '3.8' services: db: image: postgres:12.0-alpine ports: - "5432" environment: - POSTGRES_DB=something - POSTGRES_USER=user - POSTGRES_PASSWORD=pass web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" depends_on: - db

Farzin- Автор вопроса
arthur wayne
what returns on sudo service postgresql status sud...

sudo service postgresql status Redirecting to /bin/systemctl status postgresql.service Unit postgresql.service could not be found. ———- sudo lsof -nP | grep LISTEN docker-pr 654554 root 4u IPv6 7621032 0t0 TCP *:5432 (LISTEN) docker-pr 654554 654555 docker-pr root 4u IPv6 7621032 0t0 TCP *:5432 (LISTEN) docker-pr 654554 654556 docker-pr root 4u IPv6 7621032 0t0 TCP *:5432 (LISTEN) docker-pr 654554 654557 docker-pr root 4u IPv6 7621032 0t0 TCP *:5432 (LISTEN) docker-pr 654554 654558 docker-pr root 4u IPv6 7621032 0t0 TCP *:5432 (LISTEN) ———- docker-compose up -d db db run without any problem ———- docker-compose up -d api it runs and then stop ———- I've changed "db" to 127.0.0.1, and same error shows up again

Farzin- Автор вопроса
arthur wayne
docker-compose.yml version: '3.8' services: db...

I've changed docker compose to this, same error again

Похожие вопросы

Карта сайта