confy
confy

Reputation: 43

The pgAdmin 4 server could not be contacted: Fatal error

I upgrade PostgreSQL from 13.3 to 13.4 and got a fatal error by pgAdmin 4. I found other similar question that try to fix the problem deleting the folder: "C:\Users\myusername\AppData\Roaming\pgadmin\sessions" and running pgAdmin as admin but nothing happen. Also i completely remove postgres and reinstall it, and i installed pgAdmin with his separate installation, but nothing happen again. This is the error:

pgAdmin Runtime Environment
--------------------------------------------------------
Python Path: "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\python.exe"
Runtime Config File: "C:\Users\Alessandro\AppData\Roaming\pgadmin\runtime_config.json"
pgAdmin Config File: "D:\Program Files\PostgreSQL\13\pgAdmin 4\web\config.py"
Webapp Path: "D:\Program Files\PostgreSQL\13\pgAdmin 4\web\pgAdmin4.py"
pgAdmin Command: "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\python.exe -s D:\Program Files\PostgreSQL\13\pgAdmin 4\web\pgAdmin4.py"
Environment: 
  - ALLUSERSPROFILE: C:\ProgramData
  - APPDATA: C:\Users\Alessandro\AppData\Roaming
  - CHROME_CRASHPAD_PIPE_NAME: \\.\pipe\crashpad_6172_IWUHMIZQAVFZRPVX
  - CHROME_RESTART: NW.js|Spiacenti, si è verificato un arresto anomalo di NW.js. Riavviarlo ora?|LEFT_TO_RIGHT
  - CommonProgramFiles: C:\Program Files\Common Files
  - CommonProgramFiles(x86): C:\Program Files (x86)\Common Files
  - CommonProgramW6432: C:\Program Files\Common Files
  - COMPUTERNAME: HP820G1-ALESSAN
  - ComSpec: C:\WINDOWS\system32\cmd.exe
  - DriverData: C:\Windows\System32\Drivers\DriverData
  - FPS_BROWSER_APP_PROFILE_STRING: Internet Explorer
  - FPS_BROWSER_USER_PROFILE_STRING: Default
  - HOMEDRIVE: C:
  - HOMEPATH: \Users\Alessandro
  - JD2_HOME: D:\Program Files\JDownloader2
  - JDK_HOME: D:\Program Files\Java\jdk-16.0.2
  - LOCALAPPDATA: C:\Users\Alessandro\AppData\Local
  - LOGONSERVER: \\HP820G1-ALESSAN
  - NUMBER_OF_PROCESSORS: 4
  - OneDrive: D:\temp\OneDrive - Università di Salerno
  - OneDriveCommercial: D:\temp\OneDrive - Università di Salerno
  - OS: Windows_NT
  - Path: D:\Program Files\Python39\Scripts\;D:\Program Files\Python39\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\UltraEdit;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\Program Files\MATLAB\R2021a\bin;D:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;D:\Program Files\Zerynth\ztc\windows64;D:\Program Files\PostgreSQL\13\bin;C:\Users\Alessandro\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Java\jdk-16.0.2;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\Program Files\Microsoft VS Code\bin;D:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;D:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\bin;C:\Users\Alessandro\zerynth3\dist\sys\cli;D:\Program Files\PostgreSQL\13\bin;
  - PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
  - PGADMIN_INT_KEY: 89448562-228e-4522-bc29-54d857da3f2a
  - PGADMIN_INT_PORT: 55190
  - PGADMIN_SERVER_MODE: OFF
  - PROCESSOR_ARCHITECTURE: AMD64
  - PROCESSOR_IDENTIFIER: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
  - PROCESSOR_LEVEL: 6
  - PROCESSOR_REVISION: 4501
  - ProgramData: C:\ProgramData
  - ProgramFiles: C:\Program Files
  - ProgramFiles(x86): C:\Program Files (x86)
  - ProgramW6432: C:\Program Files
  - PSModulePath: C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
  - PUBLIC: C:\Users\Public
  - PyCharm Community Edition: D:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\bin;
  - SESSIONNAME: Console
  - SystemDrive: C:
  - SystemRoot: C:\WINDOWS
  - TEMP: C:\Users\ALESSA~1\AppData\Local\Temp
  - TMP: C:\Users\ALESSA~1\AppData\Local\Temp
  - USERDOMAIN: HP820G1-ALESSAN
  - USERDOMAIN_ROAMINGPROFILE: HP820G1-ALESSAN
  - USERNAME: Alessandro
  - USERPROFILE: C:\Users\Alessandro
  - windir: C:\WINDOWS
--------------------------------------------------------

Traceback (most recent call last):
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\web\pgAdmin4.py", line 39, in <module>
    import config
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\web\config.py", line 25, in <module>
    from pgadmin.utils import env, IS_WIN, fs_short_path
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\web\pgadmin\__init__.py", line 24, in <module>
    from flask_socketio import SocketIO
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\flask_socketio\__init__.py", line 9, in <module>
    from socketio import socketio_manage  # noqa: F401
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\socketio\__init__.py", line 9, in <module>
    from .zmq_manager import ZmqManager
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\socketio\zmq_manager.py", line 5, in <module>
    import eventlet.green.zmq as zmq
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\eventlet\__init__.py", line 17, in <module>
    from eventlet import convenience
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\eventlet\convenience.py", line 7, in <module>
    from eventlet.green import socket
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\eventlet\green\socket.py", line 21, in <module>
    from eventlet.support import greendns
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\eventlet\support\greendns.py", line 401, in <module>
    resolver = ResolverProxy(hosts_resolver=HostsResolver())
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\eventlet\support\greendns.py", line 315, in __init__
    self.clear()
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\eventlet\support\greendns.py", line 318, in clear
    self._resolver = dns.resolver.Resolver(filename=self._filename)
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\dns\resolver.py", line 543, in __init__
    self.read_registry()
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\dns\resolver.py", line 720, in read_registry
    self._config_win32_fromkey(key, False)
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\dns\resolver.py", line 674, in _config_win32_fromkey
    self._config_win32_domain(dom)
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\dns\resolver.py", line 639, in _config_win32_domain
    self.domain = dns.name.from_text(str(domain))
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\dns\name.py", line 889, in from_text
    return from_unicode(text, origin, idna_codec)
  File "D:\Program Files\PostgreSQL\13\pgAdmin 4\python\lib\site-packages\dns\name.py", line 852, in from_unicode
    raise EmptyLabel
dns.name.EmptyLabel: A DNS label is empty.

I don't understand why a DNS Problem is raised, anyone has suggestion or fix? Thanks.

Upvotes: 4

Views: 2233

Answers (1)

Bruno
Bruno

Reputation: 122599

This is something that seem to have changed between pgAdmin4 5.1 and 5.7. I've seen this on a machine that had been connected to a WiFi mobile hotspot (but it could happen in other circumstances).

It has something to do with the way the dns library is used on Windows, so this could happen to other applications that use it in the same way.

Essentially, dns.Resolver scans the Windows registry for all network interfaces found under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\

Registry content example

The WiFi mobile hotspot that machine had been connected to had set a DhcpDomain key with value ".home". The dns.Resolver found this value and split it using the dot into multiple labels, one of them being empty. That caused the exception you mention: dns.name.EmptyLabel: A DNS label is empty.

This occurred even when the WiFi network was turned off: those were the last settings that had been in use and dns.Resolver didn't check whether the interface was enabled.

The latest version of pgAdmin seems to be an older version of dnspython (1.16.0), so I'm not sure whether this has been fixed in more recent versions. For now, there seems to be two options:

  • Delete or change the DhcpDomain subkey if you find it in on of the subkeys of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\ (there might even be a way to force that value through the Control Panel).

  • Connect to a different network that doesn't set this value.

Upvotes: 2

Related Questions