Postgresql localhost 连接 - 连接被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10823534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-20 23:57:35  来源:igfitidea点击:

Postgresql localhost connection - Connection refused

djangopostgresql

提问by user1407540

i just installed pgadmin iii and try to connect server.

我刚刚安装了 pgadmin iii 并尝试连接服务器。

I configured my setting

我配置了我的设置

name:localhost
host: 127.0.0.1
port:5432

username:postgres

but i always get this error

但我总是收到这个错误

The server doesn't accept connection: the connection library reports **could not connect to server : Connection refused Is server runing on host "127.0.0.1" and accepting TCP/IP connections on port 5432?

服务器不接受连接:连接库报告**无法连接到服务器:连接被拒绝 服务器是否在主机“127.0.0.1”上运行并接受端口 5432 上的 TCP/IP 连接?

However, i'm runing django and python on 127.0.0.1 What's missing?

但是,我在 127.0.0.1 上运行 django 和 python 缺少什么?

There's also a problem with mysql. I could not connect with them

mysql也有问题。我无法与他们联系

回答by Cezar Romaniuc

If you change the pg_hba.conf file to accept connections (for example: "host all all 127.0.0.1 255.255.255.0 trust") it should work

如果您更改 pg_hba.conf 文件以接受连接(例如:“host all all 127.0.0.1 255.255.255.0 trust”)它应该可以工作

回答by Karl Fjellstrom

Installing postgre v12 before uninstalling v11 I found the config file (postgresql.conf) had a line "port = 5433". Changing this to "port = 5432" fixed the issue for me.

在卸载 v11 之前安装 postgre v12 我发现配置文件 (postgresql.conf) 有一行“port = 5433”。将其更改为“端口 = 5432”为我解决了这个问题。