0

Whenever I install PostgreSQL, it stops working after about 6 months. This is the second time this happened! Last time this happened, I uninstalled and then installed version 4.29. How can I debug the PostgreSQL client or server and get a stack trace?

enter image description here

enter image description here

enter image description here

Splash screen opens and never closes unless I click on it.

enter image description here

enter image description here

enter image description here

I can't show more of the top section of the log because the error dialog pops up. When closing the error, the system tray icon for PostgreSQL crashes and closes everything.

enter image description here

enter image description here

After further troubleshooting, I found 8 "PostgreSQL Server" tasks, 1 pg_ctl task, 1 pgAdmin 4 Desktop Runtime in the Task Manager. Killed them all and restarted this and restarted the service in Admin Tools > Services. Same behavior.

C:\Program Files\PostgreSQL\12\bin\postgres.exe

1

Found these. We'll give it a shot.

https://wiki.postgresql.org/wiki/Getting_a_stack_trace_of_a_running_PostgreSQL_backend_on_Linux/BSD

https://wiki.postgresql.org/wiki/Getting_a_stack_trace_of_a_running_PostgreSQL_backend_on_Windows


Windows debugging.

Open Environment Variables (WINDOWS key + BREAK) Set environment variable "_NT_SYMBOL_PATH" for 4.2.

C:\Program Files\PostgreSQL\12\debug_symbols;SRV*c:\localsymbols*http://msdl.microsoft.com/download/symbols
  • open pgAdmin 4 > look for process in Task Manager and get process id
  • open Microsoft Visual Studio (run as administrator) > Debug > Attach to Process > check "Show processes from all users" > sort by process id > Attach
  • now go back in pgAdmin

enter image description here

Got a new popup I've never seen before from Visual Studio!

enter image description here

Created new virtual environment based on Python 3.8.

enter image description here

Created a new Visual Studio Project using Python, not C++. I might need a newer version of Python based on this fix.

https://github.com/microsoft/ptvs/issues/5853

https://bugs.python.org/issue37633

Since this new version does not show in the Base Interpreter, I created a new environment based on the zip file.

enter image description here

None of that worked. Then I stumbled upon the registry configuration for pgAdmin. I read that pgAdmin uses Python version 2.7. And the PythonPath variable was blank, so I set it to C:\Python\Python27. So it must be using a value from somewhere else to get the path. It's looking in sys.path in Python whatever that is.

enter image description here

Then I set ApplicationPath to C:\Program Files\pgAdmin 4\v4\web, to the folder where pgadmin4.py is located.

Here is the icon I'm clicking on each time. "C:\Program Files\pgAdmin 4\v4\runtime\pgAdmin4.exe" "C:\Program Files\PostgreSQL\12\pgAdmin 4\bin\pgAdmin4.exe"

ERROR flask.app: Error starting the app server: (<class 'OSError'>, OSError(10013, 'An attempt was made to access a socket in a way forbidden by its access permissions', None, 10013, None),

There are two pgAdmin folders. There are traces left over from the other pgAdmin uninstall.

C:\Program Files (x86)\pgAdmin 4\files.txt
C:\Program Files (x86)\pgAdmin 4\v4
C:\Program Files (x86)\pgAdmin 4\v4\venv
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\collections
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\encodings
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\importlib
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\json
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\site-packages
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\collections\__pycache__
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\collections\__pycache__\__init__.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\encodings\__pycache__
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\encodings\__pycache__\aliases.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\encodings\__pycache__\cp1252.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\encodings\__pycache__\latin_1.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\encodings\__pycache__\utf_8.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\encodings\__pycache__\__init__.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\importlib\__pycache__
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\importlib\__pycache__\abc.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\importlib\__pycache__\machinery.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\importlib\__pycache__\util.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\importlib\__pycache__\__init__.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\json\__pycache__
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\json\__pycache__\decoder.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\json\__pycache__\encoder.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\json\__pycache__\scanner.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\json\__pycache__\__init__.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\site-packages\__pycache__
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\site-packages\__pycache__\_virtualenv.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\abc.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\codecs.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\contextlib.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\copyreg.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\datetime.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\enum.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\functools.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\genericpath.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\heapq.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\io.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\keyword.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\ntpath.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\operator.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\os.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\re.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\reprlib.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\signal.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\site.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\sre_compile.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\sre_constants.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\sre_parse.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\stat.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\subprocess.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\threading.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\types.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\warnings.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\_bootlocale.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\_collections_abc.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\_sitebuiltins.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\_weakrefset.cpython-38.pyc
C:\Program Files (x86)\pgAdmin 4\v4\venv\Lib\__pycache__\__future__.cpython-38.pyc

FINALLY SOLVED IT! Flask within the Qt framework is NOT getting the port! I put some troubleshooting code into the source code.

C:\Program Files\pgAdmin 4\v4\web\pgAdmin4.py

# Initialize Flask service only once
# If `WERKZEUG_RUN_MAIN` is None, i.e: app is initializing for first time
# so set `use_reloader` = False, thus reload won't call.
# Reference:
# https://github.com/pallets/werkzeug/issues/220#issuecomment-11176538
with open("myfile.txt", "w") as file1:
    file1.write("Testing")
    file1.write(config.DEFAULT_SERVER)
    file1.write(config.EFFECTIVE_SERVER_PORT)
try:
    app.run(
        host=config.DEFAULT_SERVER,
        port=config.EFFECTIVE_SERVER_PORT,
        use_reloader=(
            (not app.PGADMIN_RUNTIME) and app.debug and
            os.environ.get("WERKZEUG_RUN_MAIN") is not None
        ),
        threaded=config.THREADED_MODE
    )

except IOError:
    app.logger.error("Error starting the app server: %s", sys.exc_info())
8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.