使用 postgreSQL 在 pgAdmin III 中“服务器不听”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32475399/
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-09-09 06:04:43  来源:igfitidea点击:

"Server doesn't listen" in pgAdmin III with postgreSQL

postgresql

提问by Oscar Pasta

First of all : I'm a novice in what touches to databases.

首先:我是数据库方面的新手。

I'm using postgreSQL with pgAdmin III, and it worked perfectly fine until some days ago : Some days ago, when I was not working on it, I saw in the "background process" of Windows that several identical postgreSQL programs (?) were running, and I decided to stop them, because I was not using them at the time. Mistake : Now, when I try to connect to the server (on localhost), I receive the error message :

我正在将 postgreSQL 与 pgAdmin III 一起使用,直到几天前它都运行良好: 几天前,当我不使用它时,我在 Windows 的“后台进程”中看到几个相同的 postgreSQL 程序(?)跑步,我决定阻止它们,因为我当时没有使用它们。错误:现在,当我尝试连接到服务器(在本地主机上)时,我收到错误消息:

"Server doesn't listen"

The server doesn't accept connections: the connection library reports could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

“服务器不听”

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

I already took a look on similar topics on stackoverflow, looked the listen_address file, the postgresql.conf and pg_hba.conf files, but everything seems to be "normal" (according to what I read in these topics).

我已经在 stackoverflow 上查看了类似的主题,查看了 listen_address 文件、postgresql.conf 和 pg_hba.conf 文件,但一切似乎都是“正常的”(根据我在这些主题中读到的内容)。

I posted this because... well, I didn't find any other person that did what I did (stopping the background process, and then not being able to reconnect).

我发布这个是因为......好吧,我没有找到任何其他人做我所做的事情(停止后台进程,然后无法重新连接)。

回答by user6119673

Use Services (Start → Run → services.msc) and look for the postgresql-[version] service. Is it running?

使用服务(开始 → 运行 → services.msc)并查找 postgresql-[version] 服务。它在运行吗?

  • If not, try to start it.
    • If that works, you can make it startup automatically by changing the Startup Type with Windows to Automatic; or perhaps Automatic, delayed startif you don't want it to slow down startup too much.
  • If you can't start it, you may have just installed pgAdmin and not installed PostgreSQL itself.
  • If it won't start open the Event Viewer (Start → Run → Eventvwr) and look for error messages relating to the PostgreSQL service.
  • 如果没有,请尝试启动它。
    • 如果可行,您可以通过将 Windows 的启动类型更改为自动启动Automatic;或者,Automatic, delayed start如果您不希望它过多地减慢启动速度。
  • 如果您无法启动它,您可能只是安装了 pgAdmin 而没有安装 PostgreSQL 本身。
  • 如果它无法启动,请打开事件查看器(开始 → 运行 → Eventvwr)并查找与 PostgreSQL 服务相关的错误消息。

回答by Luca Perico

Edit \data\postgresql.conffind and edit this line listen_addressesto

编辑\data\postgresql.conf查找并将此行编辑listen_addresses

listen_addresses = '*'

and uncomment

并取消注释

port = 5432

回答by Calipso

For security reasons, PostgreSQL does not listen on all available IP addresseson the server machine initially. In order to access the server over the network, you need to enable listening on the address first.

出于安全原因,PostgreSQL最初不会侦听服务器计算机上所有可用的 IP 地址。为了通过网络访问服务器,您需要先启用对地址的侦听。

For PostgreSQL servers starting with version 8.0, this is controlled using the "listen_addresses" parameter in the postgresql.conf file. Here, you can enter a list of IP addresses the server should listen on, or simply use ''* to listen on all available IP addresses. For earlier servers(Version 7.3 or 7.4), you'll need to set the "tcpip_socket"parameter to 'true'.

对于从8.0 版开始的 PostgreSQL 服务器,这是使用postgresql.conf 文件中的“listen_addresses”参数控制的。在这里,您可以输入服务器应该侦听的 IP 地址列表,或者简单地使用“”* 来侦听所有可用的 IP 地址。对于较早的服务器(版本 7.3 或 7.4),您需要将"tcpip_socket"参数设置为'true'

You can use the postgresql.conf editor that is built into pgAdmin III to edit the postgresql.conf configuration file. After changing this file, you need to restart the server processto make the setting effective.

您可以使用 pgAdmin III 中内置的 postgresql.conf 编辑器来编辑 postgresql.conf 配置文件。更改此文件后,需要重新启动服务器进程才能使设置生效。

If you double-checked your configuration but still get this error message, it's still unlikely that you encounter a fatal PostgreSQL misbehaviour. You probably have some low level network connectivity problems (e.g. firewall configuration). Please check this thoroughly before reporting a bug to the PostgreSQL community.

如果您仔细检查了您的配置但仍然收到此错误消息,那么您仍然不太可能遇到致命的 PostgreSQL 错误行为。您可能有一些低级别的网络连接问题(例如防火墙配置)。在向 PostgreSQL 社区报告错误之前,请彻底检查这一点。

Credits: PostgreSQL - Guru Hint.

学分:PostgreSQL - 大师提示。

回答by Calipso

If on Windows, it could be a Firewall issue. Try adding rules (TCP as protocol should work) for postgres using post 5432 (or whatever post you might use).

如果在 Windows 上,则可能是防火墙问题。尝试使用 post 5432(或您可能使用的任何帖子)为 postgres 添加规则(TCP 作为协议应该工作)。

回答by Kev14a

Just go to task manager -> services -> postgresql-x64-9.4 - PostgreSQL Server 9.4(right click) -> start service From there just refresh postgresql and connect, and everything will be fine.

只需转到任务管理器 -> 服务 -> postgresql-x64-9.4 - PostgreSQL Server 9.4(右键单击)-> 启动服务从那里刷新 postgresql 并连接,一切都会好起来的。

回答by Goku__

I tried all the given methods. The postgresql service was running fine. Finally, logged in as administrator in Windows. It worked. Guess, postgresql doesn't allow itself to be run in a non-admin user.

我尝试了所有给定的方法。postgresql 服务运行良好。最后,在 Windows 中以管理员身份登录。有效。猜猜,postgresql 不允许自己在非管理员用户中运行。