[英]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.