无法联系pgAdmin 4服务器

问题描述

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

这是来自运行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.

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

解决方法

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

我的电脑的主机名是引起此问题的原因,因为它的主机名中包含一个'æ',它是一个非ASCII字符。因此,主机名(如果用于pgadmin)显然只能包含ASCII字符。

解决方案是将主机名更改为不带'æ'的名称(在我的情况下为-e)。主机名是计算机的实际名称,可以在系统属性(此计算机 then 属性)下找到和编辑。

,

下载 pgAdmin4 at: 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。