X2Go Bug report logs - #1639
X2Go Client (Macos): Invalid localhost port 65536 due to port detection failure on MacOS Tahoe

Packages: 4.1.2.3, x2go; Maintainer for 4.1.2.3 is (unknown); Maintainer for x2go is (unknown);

Reported by: ANDREW ERICKSON <ANDREW.ERICKSON@student.csn.edu>

Date: Wed, 4 Nov 2026 23:20:02 UTC

Severity: normal

Full log


Message #5 received at submit@bugs.x2go.org (full text, mbox, reply):

Received: (at submit) by bugs.x2go.org; 4 Nov 2026 23:17:20 +0000
From ANDREW.ERICKSON@student.csn.edu  Thu Nov  5 00:17:17 2026
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on
	ymir.das-netzwerkteam.de
X-Spam-Level: **
X-Spam-Status: No, score=2.1 required=3.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,FORGED_SPF_HELO,GOOG_REDIR_NOTRDNS,
	HTML_MESSAGE,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_ZEN_BLOCKED_OPENDNS,
	SPF_HELO_PASS,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS,URI_DOTEDU,
	URI_DOTEDU_ENTITY autolearn=no autolearn_force=no version=4.0.0
Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazlp170100005.outbound.protection.outlook.com [IPv6:2a01:111:f403:c111::5])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id E7C0C5DA4D
	for <submit@bugs.x2go.org>; Thu,  5 Nov 2026 00:17:16 +0100 (CET)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=bJqB4dx1uPYaFzb2+Ab97X0xUVIEoqH4scYr3kvQczZc7ags1G3sEg5uG5evVq2Q+weQjXkgbm2ySZ2WA+w6b3UKI0wEbYY9OoOroJTY0vjPJjUda92HK3KmJxuYzEWBi6vmfeei7Pcz6rpFAxTSXktMxdNUvI8lWttDfEng3Cw0KnrTBCMzn9ckJId7njf2dM4eSnpOOedThjwdsW5X2Kr7LWjMzFWJPGeFgvMguNoUzc+4YpQiwdfFdSvKvJaxuCGqf6zYFcaI8Mxt5grGv32a68D23fMz9nDikSML3e1LIeYVUlwQABy7pMa4TZGLz+FBl5UPKNST4nelTF972Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001; h=From:Date:Subject:Message-ID:MIME-Version;
 bh=eEIsA/tzLH7P3N8PLACGsjYEBU/U3HsYxVJWA1cZsJw=;
 b=svOFzOgaAVvHUHbagT/HLBTOArMK74MTbFjj5NAgu0SfCtRcghowtjJNBODldEc/DiN0G0IsVIDQjFW7x3l/xsvY5oAIWlCjeomHoeoJOKbI5L3pte0mVdblV7tKLsxk9/SIwoPuT5UESpilzUSEOwwNGc/kTFAY+7s+jgNK005xEOV9dzisg/bFrosT/5A8SDd5wbroefr44Dvnu50w+TPyyWOzxxLg9Bgk9d233p35nj7GVavWpWyJNhjMCRgPOI/lwccapbPgSIM3hCX3bCrNY3YvzZIRNuj7My6vOtJXd+Cf6LgJW3/ZSyr3MnwCxpl7nCpMGtx6xxeeuuJsmw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=student.csn.edu; dmarc=pass action=none
 header.from=student.csn.edu; dkim=pass header.d=student.csn.edu; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=student.csn.edu;
 s=selector2;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=eEIsA/tzLH7P3N8PLACGsjYEBU/U3HsYxVJWA1cZsJw=;
 b=Rg6lbB6brU5ZKQKptpVnxVeCEGNy8rcZ7L9PaebRtof+qDy4S9zDXjNeyIsJsjzJZ9MsmqHUIhjtraVelaKER4tGuGefCbQ0yzEDvUO5SW1kiHQLhOwkYnUpnIBJL7LSnwS4fX7E58Y9+Ccnx92m1fO7w0cYtEI5HEkVoq0IOFw=
Received: from CH3PR05MB10278.namprd05.prod.outlook.com
 (2603:10b6:610:15b::22) by DS0PR05MB9568.namprd05.prod.outlook.com
 (2603:10b6:8:131::15) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.569.12; Wed, 4 Nov
 2026 23:14:17 +0000
Received: from CH3PR05MB10278.namprd05.prod.outlook.com
 ([fe80::e271:281e:ae27:ba19]) by CH3PR05MB10278.namprd05.prod.outlook.com
 ([fe80::e271:281e:ae27:ba19%6]) with mapi id 15.21.0592.009; Wed, 4 Nov 2026
 23:14:17 +0000
From: ANDREW ERICKSON <ANDREW.ERICKSON@student.csn.edu>
To: "submit@bugs.x2go.org" <submit@bugs.x2go.org>
Subject: X2Go Client (Macos): Invalid localhost port 65536 due to port
 detection failure on MacOS Tahoe
Thread-Topic: X2Go Client (Macos): Invalid localhost port 65536 due to port
 detection failure on MacOS Tahoe
Thread-Index: AQHdbLIR7wCbdZHD1Uy+Wchmdpr2Og==
Date: Wed, 4 Nov 2026 23:14:17 +0000
Message-ID:
 <CH3PR05MB10278D2DC8F7CD5E584477B7DB8682@CH3PR05MB10278.namprd05.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: mx.microsoft.com 1; dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=student.csn.edu;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: CH3PR05MB10278:EE_|DS0PR05MB9568:EE_
x-ms-office365-filtering-correlation-id: fcc5c0ed-bafd-4429-3122-08df3ac9597a
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|366016|23010399003|376014|1800799024|786006|6133799003|10067099003|261102123227099003|18002099003|8096899003|38070700021|261028144727099003|56012099006|11063799006|261022105027099003|261022113327099003|261026140227099003|261026121527099003|261021121427099003|261021135927099003|261022075727099003;
x-microsoft-antispam-message-info:
 5dgKwS7hWB1qU5azMSWhmIaovlZebqMtPwFSvLy8HrsEY7qv0LTwH+sLdixC84zBlgTgKGanEJS6j2btNB/c8vJHnY9RHMU/GfZvqIKcEU8btAb/P9redFuzCca6mx8HVrjDKq3HVNe4EDfUIQjvHUxfmv18Lk2wzudHbrigbBsHGRNjm3a11VTyXX1uubV8XaIHofrcJTKXC6gztMAvX0l1SKLjgltrxLsq+PD+zsJvMpId4KrxzKSCofRNm31nJ3BDjtTXxAXHQ+Kw4cnLAK/KlyyQZn94SBW5VVkh9Bng67cGFLw4sZORYbvmh2pfO48kLOiDakIUszmyDGbgK9YZomu0QsaXMUMr3pdhS826J5me6gwcqKCxRyXtAVzQLLrPQGWeXlH7SkrWd2T0e35/MT4bXZBZ3g+jnKs+DjAvyzTXBMFGX3ADghXHf7FNLQsraBFboA+CsUyXhSfsm7dJE+H0cgjbHcviab2CybMO2Z/tEHMxpXeqfEBxcFNQsTjZ61o15Ttkc06Q+G2zW4115Tc+9dwIu0TSP3fTG7Qw6tMDuOcsR4/YhpqUZsQPzV7XfGNFOYtav28lGxZ46EpsZQ92apad2ffOURQ7DP0vQJZOkJp4Xy2MdE64pS8h1jifxscRMQ3QO236VQktQAf7LPaxzK2A3y9KUanSkLg=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR05MB10278.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(376014)(1800799024)(786006)(6133799003)(10067099003)(261102123227099003)(18002099003)(8096899003)(38070700021)(261028144727099003)(56012099006)(11063799006)(261022105027099003)(261022113327099003)(261026140227099003)(261026121527099003)(261021121427099003)(261021135927099003)(261022075727099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 mpT7G4lXJA37uaJDKN1YDuf57/ioI7DWpn/Psh51Di/x0c6AUaEBeLRk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N8wAIzpxR6fX6Idc6RP0wpgluQGayTvnKfR1o4LbuA0S5YTRD1d0Ut0KL9xbYtdfwV3tQemMaYQQBtw3USv0ngxUYb+VGnhvuKcjrTX8WhkYnCk8jtpcFxkl3/pCoTbF+2rdbEQqQnaZ/22TGV4nzWFw1DumM1tCk4tmVPXuC0oDzeIciwfq9q0209Da+OLt4dY8MpBFRI5LoGGhN1CqpKSL2cjA1p4cslQYjP7m63Cx+pu8VVSmxBzY+Hc8LciLXujt6hLIPR16TI6nbgoALPVZJQzUKJ7teXFoE2JwxPcZaUC9fGFQT1qwE4kWjR9v1Deq84nfvA4P9UzlFFcte4OSovSQ/pK4uSDN82qxY4AxTKBzYDGkFQN+Dh2iYyvYBwXbbEpZ/q/K3XipaqcH48yR1PvixZrHUXximRKy1NB75bWBbjN/2Flw+tXtov2TYo62KRe/1+2cT11+MVk2Et6xWR42es41D7MpGucfCudAT0F2vjSNxJu/VUQWDnY9f+wad+Zca1+UckMIcT6NYF6VXvCEwkhab/jXNwH/7edHXqOaEzNgbIJ3DBrjEq13uPA7sUb2zV61RVLWgXnio9pt3Q2pnOhyqjxHiWR9q2Ic4A==
Content-Type: multipart/alternative;
	boundary="_000_CH3PR05MB10278D2DC8F7CD5E584477B7DB8682CH3PR05MB10278na_"
MIME-Version: 1.0
X-OriginatorOrg: student.csn.edu
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: CH3PR05MB10278.namprd05.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: fcc5c0ed-bafd-4429-3122-08df3ac9597a
X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Nov 2026 23:14:17.3504
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: df35d574-9fba-48ce-a073-737868d77a48
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: N5BgjfhneoA9gI3x4Mk0fazxOu/Z644gQx4bPtTiCqOctqjLj2o4SWYL1Atnrnn0E+gbpIzIcmL3VKGezcDmN9MP1giZbqLFDHCdx3l7WMY=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR05MB9568
[Message part 1 (text/plain, inline)]
Package: X2go 4.1.2.3
Also on 4.1.2.2
MacOS Tahoe 26.7.2
Qt 4.8.7, Qt 5.15.9

Hello,

I recently ran into an issue connecting to our college's Linux server with X2go, it seemed like it was trying to connect to invalid TCP ports.  Chat GPT assisted in patching and getting it working for me, and I am providing the summary here:

X2Go on macOS Tahoe – Troubleshooting Summary and Fix
1. The original problem
I was unable to connect to my college's Linux server (bellagio.csn.edu<http://bellagio.csn.edu/>) using X2Go Client on my MacBook Air.
My configuration was:
Component
Version
macOS
Tahoe 26.7.2
X2Go Client
4.1.2.2
NXProxy
3.5.99.20
XQuartz
2.8.6
Mac architecture
Apple Silicon (ARM64)
The connection worked successfully from my Windows computer, and SSH connections from my Mac also worked.
The original X2Go error was:

Info: Connecting to remote host 'localhost:65536'.

Port 65536 is invalid because the maximum TCP port is 65535.
2. Root cause
We investigated the X2Go Client 4.1.2.2 source code and eventually reproduced the problem independently.
The relevant function was:

bool ONMainWindow::isServerRunning(int port)
{
    QTcpSocket tcpSocket(0);
    tcpSocket.connectToHost("127.0.0.1", port);

    if (tcpSocket.waitForConnected(1000))
    {
        tcpSocket.close();
        return true;
    }

    return false;
}

This function determines whether a local TCP port is already occupied.
However, our testing on macOS Tahoe demonstrated unexpected Qt behavior: QTcpSocket::waitForConnected() reported successful connections to ports where no listening service existed.
We verified this using a standalone Qt test and compared it against Python socket tests and lsof.
As a result, X2Go incorrectly believed that every candidate local port was occupied.
Its port-selection loop kept incrementing until it reached 65536.
We reproduced the same problem with X2Go Client 4.1.2.3, so simply upgrading the client wasn't sufficient.
3. The actual fix we applied
We installed X2Go Client 4.1.2.3 through MacPorts and modified its source code.
Change 1: Replace the port availability test on macOS.
Instead of using QTcpSocket::connectToHost(), we used QTcpServer::listen().
The replacement code was:

#ifdef Q_OS_DARWIN
    // Determine port availability by binding a local listening socket.
    if (port < 1 || port > 65535)
        return true;

    QTcpServer tcpServer;

    if (tcpServer.listen(QHostAddress::LocalHost,
                         static_cast<quint16>(port)))
    {
        tcpServer.close();
        return false;
    }

    return true;
#else
    QTcpSocket tcpSocket(0);
    tcpSocket.connectToHost("127.0.0.1", port);

    if (tcpSocket.waitForConnected(1000))
    {
        tcpSocket.close();
        return true;
    }

    return false;
#endif

The new implementation attempts to bind and listen on the candidate port:

  *
If binding succeeds, the port is available.
  *
If binding fails, the port is treated as unavailable.

This avoids the unexpected connection-test behavior we observed on macOS.
Change 2: Prevent invalid TCP port selection.
We also modified the graphics-port selection loop.
Original:

localGraphicPort = resumingSession.grPort;
int iport = localGraphicPort.toInt() + 1000;

while (iport == resumingSession.sndPort.toInt() ||
       iport == resumingSession.fsPort.toInt() ||
       isServerRunning(iport))
    ++iport;

localGraphicPort = QString::number(iport);

Patched:

localGraphicPort = resumingSession.grPort;
int iport = localGraphicPort.toInt() + 1000;

while (iport <= 65535 &&
       (iport == resumingSession.sndPort.toInt() ||
        iport == resumingSession.fsPort.toInt() ||
        isServerRunning(iport)))
    ++iport;

if (iport > 65535)
{
    QMessageBox::critical(
        this,
        tr("X2Go Client"),
        tr("No available local TCP port could be found for this session.")
    );
    return;
}

localGraphicPort = QString::number(iport);

This ensures X2Go never attempts to use a port outside the valid TCP range.
4. Additional macOS Tahoe workaround
There was a separate compatibility issue involving XQuartz.
Starting with macOS 26.4, Apple changed the location of the XQuartz display socket.
Our college provided a launcher that worked around this by:

  1.
Detecting the active XQuartz socket.
  2.
Creating a temporary symbolic link under /tmp/launchXXXXXX.
  3.
Setting the DISPLAY environment variable to the compatible path.
  4.
Launching X2Go Client.
  5.
Cleaning up the temporary directory afterward.

We retained this workaround and used it when launching our patched client.
5. Successful result
Resolved
We rebuilt the patched X2Go Client 4.1.2.3 through MacPorts and tested the staged application before installing or replacing anything.
The successful debug log showed:

Starting tunnel via SshProcess object 2:
"localhost":50729 -> "localhost":51729

Then:

Direct tunnel: waiting for connections on "localhost":51729

And finally:

Info: Connecting to remote host 'localhost:51729'.
Info: Connected to remote proxy on FD#5.

The client successfully connected to the college Linux server and launched Geany.
No changes to the college Linux server were necessary.
6. Final working setup
We copied the patched application to:

~/Applications/X2Go Client Patched.app

We also created a desktop launcher:

~/Desktop/X2Go-Tahoe.command

The launcher automatically applies the XQuartz compatibility workaround and starts the patched client.
The original college-provided launcher and original X2Go installation were left intact.
Final summary
Problem
Resolution
macOS Tahoe changed XQuartz socket location
College-provided launcher creates compatibility symlink
Qt port detection incorrectly reported ports as occupied
Replaced connection-based test with QTcpServer::listen() on macOS
X2Go selected invalid port 65536
Added TCP port-range validation
X2Go timed out connecting to NXProxy
Resolved by selecting a valid local tunnel port
Original installation needed to be preserved
Created separate patched application and desktop launcher
The key technical fix was replacing X2Go's macOS QTcpSocket::waitForConnected() port-availability check with QTcpServer::listen().
One maintenance note: the fix was applied to our MacPorts source build, not upstream X2Go. A future MacPorts upgrade may overwrite it, so keep a copy of the patched source and original backup (onmainwindow.cpp.pre-darwin-portfix).
This is also a useful bug report to share with the X2Go developers and your college IT department, particularly because we reproduced the problem on both 4.1.2.2 and 4.1.2.3.




[Message part 2 (text/html, inline)]

Send a report that this bug log contains spam.


X2Go Developers <owner@bugs.x2go.org>. Last modified: Mon Nov 9 06:25:34 2026; Machine Name: ymir.das-netzwerkteam.de

X2Go Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.