无法联系 pgAdmin 4 服务器

The pgAdmin 4 server could not be contacted

我已经安装了 PostgreSQL 12 和 pgAdmin 4。当我尝试 运行 pgAdmin 4 时,出现致命错误“无法联系 pgAdmin 4 服务器”。我试过 运行 以管理员身份运行它,删除“C:\Users\User\AppData\Roaming\pgAdmin”中的文件并将“C:\Program Files\PostgreSQL\bin”添加到系统环境变量。我不知道我还能做什么。我确定 PostgreSQL 服务器正在运行,因为它在 services.msc 的服务是 运行ning.

这是来自 运行ning pgAdmin4 的日志。我可以看到这里有问题,但我不知道如何解决这个问题:

Traceback (most recent call last):
  File "C:/Program Files/pgAdmin 4/v4/web/pgAdmin4.py", line 217, in <module>
    main()
  File "C:/Program Files/pgAdmin 4/v4/web/pgAdmin4.py", line 199, in main
    app.run(
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\flask\app.py", line 943, in run
    run_simple(host, port, self, **options)
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 1052, in run_simple
    inner()
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 996, in inner
    srv = make_server(
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 847, in make_server
    return ThreadedWSGIServer(
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 740, in __init__
    HTTPServer.__init__(self, server_address, handler)
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib\socketserver.py", line 452, in __init__
    self.server_bind()
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib\http\server.py", line 140, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:/Program Files/pgAdmin 4/v4/venv/Lib\socket.py", line 756, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 5: invalid start byte

这是另一个 .log 文件:

2020-08-31 17:15:12: Checking for system tray...
2020-08-31 17:15:12: Starting pgAdmin4 server...
2020-08-31 17:15:12: Creating server object, port:52967, key:459b0c86-b99e-46f0-9070-55554b9621d3, logfile:C:/Users/user/AppData/Local/pgadmin4.d41d8cd98f00b204e9800998ecf8427e.log
2020-08-31 17:15:12: Python Path: C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages;C:/Program Files/pgAdmin 4/v4/venv/DLLs;C:/Program Files/pgAdmin 4/v4/venv/Lib
2020-08-31 17:15:12: Python Home: C:/Program Files/pgAdmin 4/v4/venv
2020-08-31 17:15:12: Initializing Python...
2020-08-31 17:15:12: Python initialized.
2020-08-31 17:15:12: Adding new additional path elements
2020-08-31 17:15:12: Redirecting stderr...
2020-08-31 17:15:12: stderr redirected successfully.
2020-08-31 17:15:12: Initializing server...
2020-08-31 17:15:12: Webapp Path: C:/Program Files/pgAdmin 4/v4/web/pgAdmin4.py
2020-08-31 17:15:12: Server initialized, starting server thread...
2020-08-31 17:15:12: Open the application code and run it.
2020-08-31 17:15:12: Set the port number, key and force SERVER_MODE off
2020-08-31 17:15:12: PyRun_SimpleFile launching application server...
2020-08-31 17:15:13: Application Server URL: http://127.0.0.1:52967/?key=459b0c86-b99e-46f0-9070-55554b9621d3
2020-08-31 17:15:13: The server should be up. Attempting to connect and get a response.
2020-08-31 17:15:21: Failed to launch the application server, server thread exiting.

如果你知道我能做什么,请帮助我。

在自己处理了这个问题之后,出现了与给定的完全相同的错误和堆栈跟踪,我终于找到了解决方案。

我电脑的主机名是导致问题的原因,因为它包含一个 'æ',这是一个 non-ASCII 字符。所以主机名,如果用于 pgadmin,显然只能包含 ASCII 字符。

解决方案是将主机名更改为不带“æ”的名称(在我的例子中为 æ -> ae)。主机名是 pc 的实际名称,在系统属性(This PC then Properties)下找到并编辑。

在以下位置下载 pgAdmin4:https://www.postgresql.org/ftp/pgadmin/pgadmin4/v5.2/windows/ Download Sql server at: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 设置时,取消选中安装 pgAdmin 4 和 StackBuilder。

您可以尝试打开任务管理器,查找 PostgreSQL 后台进程并 End task 它们。