简体   繁体   English

如何在主机上测试Postgres数据库连接?

[英]How to test postgres database connection on host?

I used pg_isready -h localhost which gives output as localhost:5432 - accepting connections 我使用了pg_isready -h localhost ,它的输出为localhost: 5432- 接受连接

But when i used my host-ip instead of localhost ,it gives output as pg_isready -h 18.191.7.185 output is 18.191.7.185:5432 - no response 但是,当我使用host-ip而不是localhost时,它的输出为pg_isready -h 18.191.7.185,输出为18.191.7.185:5432-无响应

My localhost isn't my ip-address? 我的本地主机不是我的IP地址吗?

No, it isn't. 不,不是。 Verify with 验证

ping localhost

which will show you the IP address that localhost resolves to. 这将显示localhost解析的IP地址。

The “loopback interface” is a special network interface that only contains your computer. “环回接口”是仅包含您的计算机的特殊网络接口。

The cause of the problem is probably that the PostgreSQL parameter listen_addresses , which specifies the network interfaces on which PostgreSQL is listening, is set to the default value localhost . 问题的原因可能是PostgreSQL参数listen_addresses设置为默认值localhost ,该参数指定PostgreSQL正在监听的网络接口。

Change the value to * and restart PostgreSQL, and it should work. 将值更改为*并重新启动PostgreSQL,它应该可以工作。

A second possibility is that you have restrictive firewall settings on your machine. 第二种可能性是您的计算机上有严格的防火墙设置。 Actually, reading your question again, that is probably your problem, since you are receiving no response rather that an error saying that nothing is listening on that port. 实际上,再次阅读您的问题,这很可能是您的问题,因为您没有收到任何答复,而是收到一个错误消息,表明该端口上没有监听。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM