[英]Adding listen_address=“*” makes my postgres stop working locally
I want to login to my db both locally and also remotely through psql.我想通过 psql 在本地和远程登录我的数据库。 My config is below-
我的配置如下 -
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
When I add listen_address="*"
, my postgres stops working当我添加
listen_address="*"
时,我的 postgres 停止工作
sudo systemctl restart postgresql
ubuntu@ip-172-31-77-60:~$ psql -U postgres -h localhost
psql: error: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
I am running postgres12.我正在运行 postgres12。 How do I enable remote and local logins (psql and pgadmin?) Removing listen_address="*" and restarting fixes my postgres instance but pgadmin tells me it can't connect
如何启用远程和本地登录(psql 和 pgadmin?)删除 listen_address="*" 并重新启动修复了我的 postgres 实例,但 pgadmin 告诉我它无法连接
I did follow this question Even with listen_addresses ='*' in postgres, remote login is not working and changed the我确实遵循了这个问题即使在 postgres 中使用 listen_addresses ='*',远程登录也无法正常工作并更改了
host all all 127.0.0.1/32 md5
to至
host all all 0.0.0.0/0 md5
and I tried the plural listen_addresses = '*'
but I am still stuck.我尝试了复数
listen_addresses = '*'
但我仍然卡住了。
Setting listen_addresses = '*'
(plural) and restarting the database shouldn't disable local connections.设置
listen_addresses = '*'
(复数)并重新启动数据库不应禁用本地连接。 Check the log files to see if there is any error.检查日志文件以查看是否有任何错误。 A wrong parameter in the
postgresql.conf
is enough to prevent a database to startup. postgresql.conf
中的错误参数足以阻止数据库启动。 eg: PostgreSQL 13 on Ubuntu try:例如: Ubuntu 上的 PostgreSQL 13 尝试:
cat /var/log/postgresql/postgresql-13-main.log.1
There you will see with more details what is going on with your database.在那里,您将看到更多详细信息,您的数据库正在发生什么。
I suspect that the database couldn't be started, and since you didn't see any error message yet, you're having the impression that is started and is not accepting any connection.我怀疑数据库无法启动,并且由于您还没有看到任何错误消息,因此您的印象是已启动并且不接受任何连接。 Change the
postgresql.conf
to listen_addresses = '*'
and restart the database将
postgresql.conf
更改为listen_addresses = '*'
并重新启动数据库
$ sudo service postgresql restart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.