简体   繁体   English

Django, Docker, postgreSQL 在端口 5432 上接受 TCP/IP 连接?

[英]Django, Docker, postgreSQL Accepting TCP/IP connections on port 5432?

II am using Docker and I got this message:我正在使用 Docker,我收到了这条消息:

Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

Here is my docker-compose:这是我的 docker-compose:

version: '3.7'

services:
  web:
    container_name: web
    build:
      context: .
      dockerfile: Dockerfile
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/usr/src/web/
    ports:
      - 8000:8000
      - 3000:3000
    stdin_open: true
    depends_on:
      - db

  db:
    container_name: db
    image: postgres:12.0-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=pass
      - POSTGRES_DB=mydb
      - POSTGRES_HOST=localhost
volumes:
  postgres_data:

I precise I change the value of the parameter 'HOST' in the settings.py to db but it does not work I still have this error.我精确地将settings.py中参数'HOST'的值更改为db,但它不起作用我仍然有这个错误。

Could you help me please?请问你能帮帮我吗?

Check if your old postgres server is shutdown properly.检查您的旧 postgres 服务器是否正确关闭。 you can delete old docker images by您可以删除旧的 docker 图像

docker rmi -f $(docker images -a -q) docker rmi -f $(docker images -a -q)

docker container prune docker 集装箱修剪

then run your docker-compose然后运行你的 docker-compose

docker-compose up --build docker-compose up --build

Hope this will work.希望这会奏效。 I got similar error because I was having another postgresql running over my localhost.我遇到了类似的错误,因为我的本地主机上运行了另一个 postgresql。 You can also install postgres app which will help your db to force start and force shutdown your postgres server.您还可以安装 postgres 应用程序,它将帮助您的数据库强制启动和强制关闭您的 postgres 服务器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django/Postgresql:服务器是否在主机“xxx”上运行并接受端口 5432 上的 TCP/IP 连接? - Django/Postgresql : Is the server running on host "xxx" and accepting TCP/IP connections on port 5432? 服务器是否在主机“db”(172.28.0.2) 上运行并在端口 5432 上接受 TCP/IP 连接? Docker - Is the server running on host "db" (172.28.0.2) and accepting TCP/IP connections on port 5432? Docker EC2 和 RDS 上的 Django 应用程序(服务器是否在主机“localhost”(127.0.0.1)上运行并在端口 5432 上接受 TCP/IP 连接?) - Django application on EC2 and RDS ( Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?) 服务器是否在主机“ localhost”(127.0.0.1)上运行并在端口5432上接受TCP / IP连接? - Is the server running on host “localhost” (127.0.0.1) and accepting TCP/IP connections on port 5432? 连接到“localhost”的服务器,端口 5432 失败:连接被拒绝服务器是否在该主机上运行并接受 TCP/IP 连接? - connection to server at "localhost" , port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? 无法连接到服务器:连接被拒绝 服务器是否在主机“数据库”(172.19.0.3)上运行并接受端口 5432 上的 TCP/IP 连接? - could not connect to server: Connection refused Is the server running on host “database” (172.19.0.3) and accepting TCP/IP connections on port 5432? 505错误无法连接到服务器:连接被拒绝服务器是否在主机“ 127.0.0.1”上运行并接受端口5432上的TCP / IP连接? - 505 Error could not connect to server: Connection refused Is the server running on host “127.0.0.1” and accepting TCP/IP connections on port 5432? 无法连接到服务器:连接被拒绝。 服务器是否在主机“localhost”(127.0.0.1) 上运行并在端口 5432 上接受 TCP/IP 连接 - 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 Django、docker、PostGIS 中的错误:服务器是否在本地运行并接受 Unix 域套接字“/var/run/postgresql/.s.PGSQL”上的连接? - Error in Django,docker,PostGIS: Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”? django 无法连接到服务器:权限被拒绝服务器是否在主机上运行并在端口远程主机上接受 TCP/IP 连接 - django could not connect to server: Permission denied Is the server running on host and accepting TCP/IP connections on port remote host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM