小编Fra*_*sco的帖子

django.db.utils.OperationalError:无法连接到服务器:连接被拒绝

我有 3 个 docker 容器 web(django)、nginx、db(postgresql)

当我运行以下命令时

docker-compose -f docker-compose.prod.yml exec web python manage.py migrate --noinput
Run Code Online (Sandbox Code Playgroud)

确切的错误是:

  django.db.utils.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
    could not connect to server: Address not available
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)

docker-compose.prod.yml

version: '3.7'

services:
  db:
    image: postgres:12.0-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    env_file:
      - ./.envs/.db
  web:
    build:
      context: ./tubscout …
Run Code Online (Sandbox Code Playgroud)

django postgresql nginx gunicorn docker

1
推荐指数
1
解决办法
6839
查看次数

标签 统计

django ×1

docker ×1

gunicorn ×1

nginx ×1

postgresql ×1