diff --git a/web/pgadmin/utils/driver/psycopg3/server_manager.py b/web/pgadmin/utils/driver/psycopg3/server_manager.py index 95b3f2645d3..a1991cac4ea 100644 --- a/web/pgadmin/utils/driver/psycopg3/server_manager.py +++ b/web/pgadmin/utils/driver/psycopg3/server_manager.py @@ -652,14 +652,15 @@ def create_connection_string(self, database, user, password=None): parameters. """ dsn_args = dict() - dsn_args['host'] = \ - self.local_bind_host if self.use_ssh_tunnel else self.host + dsn_args['host'] = self.host dsn_args['port'] = \ self.local_bind_port if self.use_ssh_tunnel else self.port dsn_args['dbname'] = database dsn_args['user'] = user if self.service is not None: dsn_args['service'] = self.service + if self.use_ssh_tunnel: + dsn_args['hostaddr'] = self.local_bind_host # Make a copy to display the connection string on GUI. display_dsn_args = dsn_args.copy() @@ -680,10 +681,9 @@ def create_connection_string(self, database, user, password=None): with_complete_path = True value = get_complete_file_path(value) - # In case of host address need to check ssh tunnel flag. - if key == 'hostaddr': - value = self.local_bind_host if self.use_ssh_tunnel else \ - value + # If key is hostaddr and ssh tunnel is in use don't overwrite. + if key == 'hostaddr' and self.use_ssh_tunnel: + continue dsn_args[key] = value display_dsn_args[key] = orig_value if with_complete_path else \