pgadmin4 icon indicating copy to clipboard operation
pgadmin4 copied to clipboard

Incorrect name of tunnel host does not show DNS error

Open digitalica opened this issue 7 months ago • 3 comments

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

digitalica avatar Jul 20 '25 19:07 digitalica

@digitalica, A new issue has been created in the SSHTunnel GitHub repository: pahaz/sshtunnel#305

akshay-joshi avatar Sep 29 '25 13:09 akshay-joshi

@akshay-joshi ok. There's not much activity there, although i see one commit end of august now... who knows ;-)

digitalica avatar Oct 18 '25 16:10 digitalica

@digitalica This entirely depends on when the SSH Tunnel community resolves issue #305

akshay-joshi avatar Oct 27 '25 06:10 akshay-joshi