[英]Cannot connect to dockerized Postgres through dockerized pgAdmin
I have a docker-compose file:我有一个 docker-compose 文件:
version: '3'
services:
db:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_DB: ayyy
POSTGRES_USER: letsgo
POSTGRES_PASSWORD: pwpwpwpw22
pgadmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: user@example.com
PGADMIN_DEFAULT_PASSWORD: pwpwpwpw1
ports:
- "5433:80"
(I changed the environment variables to not spoof my credentials) (我更改了环境变量以不欺骗我的凭据)
However I am unable to connect to my Postgres server through pgAdmin.但是我无法通过 pgAdmin 连接到我的 Postgres 服务器。 pgAdmin is using reverse proxy from port 5433 to my subdomain
pgadmin.domain.com
. pgAdmin 正在使用从端口 5433 到我的子域
pgadmin.domain.com
反向代理。 I am also reverse proxying HTTP from pgAdmin's container into HTTPS.我还将 HTTP 从 pgAdmin 的容器反向代理到 HTTPS。 (I do not know if that could be an issue)
(不知道会不会有问题)
This is the error I get:这是我得到的错误:
Unable to connect to server: connection to server at "db" (192.168.32.3), port 5432 failed: timeout expired
无法连接到服务器:在“db”(192.168.32.3)处连接到服务器,端口 5432 失败:超时已过期
If I use localhost
as a hostname, I get this:如果我使用
localhost
作为主机名,我会得到:
Unable to connect to server: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?
无法连接到服务器:在“localhost”(127.0.0.1)上连接到服务器,端口 5432 失败:连接被拒绝 服务器是否在该主机上运行并接受 TCP/IP 连接? connection to server at "localhost" (::1), port 5432 failed: Address not available Is the server running on that host and accepting TCP/IP connections?
在“localhost”(::1) 上连接到服务器,端口 5432 失败:地址不可用 服务器是否在该主机上运行并接受 TCP/IP 连接?
UPDATE: I am not even able to ping the containers between each other.更新:我什至无法在彼此之间 ping 容器。 The service name is correctly resolved to IP, but I get no response.
服务名称已正确解析为 IP,但我没有收到任何响应。
I was even unable to open ports on my server, so I reinstalled it.我什至无法在我的服务器上打开端口,所以我重新安装了它。 Everything works as it should since then.
从那时起,一切都按原样运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.