尝试连接数据库时,出现以下消息:“无法连接到服务器。服务器是否在主机10.9.10.83上运行并在端口5432上接受TCP / IP连接?” 昨天与数据库的连接工作正常,但今天我收到了此消息。我关闭计算机并用完电池后,此问题立即发生,因此可能是相关的。如何修复连接?
我运行命令:postgresql-10.service status。 结果是这样的:
.gitignore
然后:
Redirecting to /bin/systemctl status postgresql-10.service
● postgresql-10.service - PostgreSQL 10 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-10.service; enabled; vendor preset: disabled)
Active: active (running) since sam. 2018-07-21 16:35:53 CEST; 41min ago
Docs: https://www.postgresql.org/docs/10/static/
Process: 4997 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 4909 ExecStartPre=/usr/pgsql-10/bin/postgresql-10-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4915 (postmaster)
CGroup: /system.slice/postgresql-10.service
├─4915 /usr/pgsql-10/bin/postmaster -D /var/lib/pgsql/10/data/
├─4917 postgres: logger process
├─4919 postgres: checkpointer process
├─4920 postgres: writer process
├─4921 postgres: wal writer process
├─4922 postgres: autovacuum launcher process
├─4923 postgres: stats collector process
├─4924 postgres: bgworker: logical replication launcher
├─4932 postgres: etpta etpta 127.0.0.1(60872) idle
├─5061 postgres: etpta etpta 127.0.0.1(33322) idle
├─7739 postgres: etpta etpta 10.9.10.83(35034) idle
├─7747 postgres: etpta etpta 10.9.10.83(35036) idle
├─7748 postgres: etpta etpta 10.9.10.83(35038) idle
├─7749 postgres: etpta etpta 10.9.10.83(35040) idle
├─7750 postgres: etpta etpta 10.9.10.83(35042) idle
├─7751 postgres: etpta etpta 10.9.10.83(35044) idle
├─7752 postgres: etpta etpta 10.9.10.83(35046) idle
├─7753 postgres: etpta etpta 10.9.10.83(35048) idle
├─7770 postgres: etpta etpta 10.9.10.83(35066) idle
├─7790 postgres: etpta etpta 10.9.10.83(35788) idle
├─7809 postgres: etpta etpta 10.9.10.83(35948) idle
├─7847 postgres: etpta etpta 10.9.10.83(35958) idle
├─7849 postgres: etpta etpta 10.9.10.83(35960) idle
├─7852 postgres: etpta etpta 10.9.10.83(35962) idle
├─7855 postgres: etpta etpta 10.9.10.83(35968) idle
├─7863 postgres: etpta etpta 10.9.10.83(35972) idle
└─7867 postgres: etpta etpta 10.9.10.83(35978) idle
答案 0 :(得分:0)
尝试
telnet 10.9.10.83 5432
如果未应答,则服务器未在此IP上侦听。 尝试
netstat -antpl | grep 5432
并检查Postgres侦听的IP,也许10.9.10.83不是正确的IP。
检查postgresql日志文件以获取线索。