将 superset 连接到 docker 容器中的 postgresql - 端口已关闭

use*_*380 7 database postgresql apache-superset

我的操作系统是Linux。
我要将 Superset 连接到 PostgreSQL。
PostgreSQL 端口已打开,其值为 5432。PostgreSQL
也在运行且未关闭。
不幸的是,经过一天的网上研究,我无法解决这个问题,并给出了以下错误:

The port is closed.
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

数据库端口:
在此输入图像描述


命令:lsof -i TCP:5432
python3 13127 user   13u  IPv4 279806      0t0  TCP localhost:40166->localhost:postgresql (ESTABLISHED)
python3 13127 user   14u  IPv4 274261      0t0  TCP localhost:38814->localhost:postgresql (ESTABLISHED)
Run Code Online (Sandbox Code Playgroud)

请帮助我,我是初学者,但我搜索了很多但没有得到任何结果。

解决方案

使用host.docker.internal代替127.0.0.1or localhost。(感谢 pdxrlk)


pdx*_*rlk 20

由于您在 Docker 容器中运行 Superset,因此您不能使用 127.0.0.1 或 localhost,因为它们解析为容器,而不是主机。对于主机,使用host.docker.internal