pgadmin-org / pgadmin-org/pgadmin4

Incorrect name of tunnel host does not show DNS error

Open
#8,976 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Waiting for upstream
Dominant language
Python
Stars
3.8k
Forks
891
Avg merge
4d 7h
Merged PRs (30d)
8

Description

arguably not a bug, but a (potential) improvement.

When registering a server, if the name of a tunnel host is typed incorrectly, and therefore cannot be resolved to an IP the error does NOT indicate a DNS issue. It just shows:

Failed to create the SSH tunnel.
Error: Could not establish session to SSH gateway

While:

  • a typo in the hostname in the connection tab without using ssh tunneling DOES show a DNS error (Temporary failure in name resolution)
  • the sshtunnel package, used for the tunneling, DOES log the DNS error (Could not resolve IP address for XXXX)

Note: investigation (see below) showed also other detailed errors in SSH tunnel are not shown.

To Reproduce

Steps to reproduce the behavior:

  1. Go to register server
  2. enter a name , and a hostname
  3. in the ssh tunnel tab: enable the tunnel, enter an non-existing name, and some random username and click 'save'
  4. See the error 'Could not establish session to SSH gateway'.

Expected behavior

A clear message, showing DNS lookup failed.

Error messages as logged (by the library, not shown to user)

2025-07-20 17:01:12,317| ERROR | Could not resolve IP address for fdsafdsa, aborting! <<<<<< logline from sshtunnel *****
2025-07-20 17:01:12,317: ERROR pgadmin: Could not establish session to SSH gateway
Traceback (most recent call last):
File "/home/robbert/git/pgadmin4/web/pgadmin/utils/driver/psycopg3/server_manager.py", line 613, in create_ssh_tunnel
self.tunnel_object.start()
File "/home/robbert/git/pgadmin4/venv/lib/python3.12/site-packages/sshtunnel.py", line 1331, in start
self._raise(BaseSSHTunnelForwarderError,
File "/home/robbert/git/pgadmin4/venv/lib/python3.12/site-packages/sshtunnel.py", line 1174, in _raise
raise exception(reason)
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
2025-07-20 17:01:12,330: INFO werkzeug: 127.0.0.1 - - [20/Jul/2025 17:01:12] "POST /browser/server/obj/1/ HTTP/1.1" 401 -

Screenshots

not requried, but just in case.

Image

Desktop (please complete the following information):

  • OS: ubuntu 24.04
  • Version: 9.5
  • Mode: server
  • Browser: firefox
  • Package type: n.a.

(but originally seen in older standalone version on Fedora, and 9.4 standalone version in Ubuntu 24.04)

Additional context

Investigation showed this is caused by the sshtunnel lib. It does NOT return the found error to caller so they can be shown. Also, the repo of sshtunnel doesnt seem to be maintained (https://github.com/pahaz/sshtunnel/, last update 2 years ago). (!!)

Maybe another library can help, or there is a feasible fork (or one can be created) or, just include the (needed) code of sshtunnel in pgadmin4 and improve...

not a high prio issue, but it took me some time to understand what the problem was, running into it. Tried to solve, but not sure what would be preferred direction. (and its not going to be a simple few line fix ;-) )

related to: https://github.com/pgadmin-org/pgadmin4/issues/3925

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at web/pgadmin/utils/driver/psycopg3/server_manager.py, especially create_ssh_tunnel, and inspect how errors from the sshtunnel package are handled. Compare the logged DNS-resolution failure with the message returned to the server registration flow; done means a failed tunnel with an unresolvable host gives the user a clear DNS-related error rather than only the generic gateway message.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.