在 CentOS 上 pgAdmin 打不开,通常不是单一原因,而是和环境、版本、权限或依赖有关。下面按最常见原因 → 对应排查方法给你一个清单,你对照看看是哪一种。
先确认一下:
现在 CentOS 上基本都是 pgAdmin 4
pgAdmin 4 在 CentOS 上通常是 HTTP 服务
检查是否运行:
systemctl status pgadmin4
如果没启动:
systemctl start pgadmin4
systemctl enable pgadmin4
然后浏览器访问:
http://服务器IP:80
或
http://localhost/pgadmin4
✅ 打不开多半是这一步
firewall-cmd --list-all
如果 80 端口没开:
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
临时关闭测试:
setenforce 0
如果能打开,说明是 SELinux 问题:
setsebool -P httpd_can_network_connect 1
查看日志:
journalctl -xe
或
/var/log/pgadmin4/pgadmin4.log
常见错误:
ModuleNotFoundErrorPostgreSQL version not supported修复方式:
pip3 install --upgrade pgadmin4
或重装:
yum reinstall pgadmin4
检查配置文件:
/etc/pgadmin4/config.py
最少应有:
SERVER_MODE = True
如果改坏了:
mv /etc/pgadmin4/config.py /etc/pgadmin4/config.py.bak
yum reinstall pgadmin4
https://IPhttp://IP/pgadmin4如果是桌面版:
pgadmin4
或
/usr/pgadmin4/bin/pgadmin4
pgAdmin 能开,但连不上库时也像“打不开”
systemctl status postgresql
systemctl status pgadmin4
systemctl status postgresql
firewall-cmd --list-all
getenforce
cat /var/log/pgadmin4/pgadmin4.log
你可以直接告诉我:
我可以直接告诉你哪一行配置或命令有问题。