在 CentOS 上 pgAdmin 打不开 的原因很多,下面按常见原因 → 排查方法 → 解决办法给你梳理一下。
CentOS 上常见有 3 种方式:
pgAdmin4 依赖 Python、WebKit、Qt 等。
现象
检查
pgadmin4
或
python3 /usr/pgadmin4/web/pgAdmin4.py
解决
sudo yum install -y epel-release
sudo yum install -y pgadmin4 pgadmin4-web
如果是桌面版:
sudo yum install -y pgadmin4-desktop
pgAdmin4 在 CentOS 上默认是 Web 模式
正确打开方式
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start pgadmin4
浏览器访问:
http://localhost/pgadmin4
现象
Permission denied检查
getenforce
临时关闭测试
sudo setenforce 0
永久解决
sudo setsebool -P httpd_can_network_connect 1
检查端口
ss -lntp | grep 80
防火墙
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
pgAdmin4 配置文件:
/etc/pgadmin4/config.py
/var/lib/pgadmin4/pgadmin4.db
重置(慎用)
rm -f /var/lib/pgadmin4/pgadmin4.db
sudo systemctl restart pgadmin4
pgAdmin4 对 Python 版本敏感(通常要求 3.7+)
python3 --version
你可以按顺序跑:
systemctl status pgadmin4
systemctl status httpd
getenforce
firewall-cmd --list-all
journalctl -xe | grep pgadmin
你可以告诉我:
我可以直接帮你定位到具体原因并给命令。