For others who get this error but have a slightly different cause, you can do the following to troubleshoot. Open a text editor by right clicking and choosing Run As Administrator. Open C:\Program Files\pgAdmin 4\v4\web\pgAdmin4.py and add one line of code without anything else. The output will be drastically different and helpful. You can find the error in the system tray > pgAdmin > View Log.
import traceback # <--- add this line too.
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())
app.logger.error("Error starting the app server: %s", traceback.format_exc()) # <--- add this line!
Instead of this:
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),
You will get this:
2021-03-01 11:38:33,817: 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), <traceback object at 0x00000279EF74A3C0>)
Traceback (most recent call last):
File "C:/Program Files/pgAdmin 4/v4/web/pgAdmin4.py", line 210, 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 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "C:/Program Files/pgAdmin 4/v4/venv/Lib\socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions