[Bug] VNC console ignores the configured Proxmox API port (hardcoded 8006)
Describe the bug
When a cluster is added with a non-default Proxmox API port, regular API calls use that port correctly, but the noVNC console always connects to port 8006 and fails with ConnectionRefusedError.
In pegaprox/api/vms.py, vnc_handler builds the upstream websocket URL with a fixed port:
tunnel_target_port = 8006
pve_ws_url = f"wss://{tunnel_target_host}:{tunnel_target_port}{pve_ws_path}"
Our setup reaches the Proxmox API through a TCP tunnel on port 18006, with nothing listening on port 8006 of that host. Everything in PegaProx works except the VNC console.
Steps to Reproduce
- Add a Proxmox VE cluster with host
Xand Proxmox API port18006, whereX:8006is closed andX:18006forwards to the node's8006. - Verify that the cluster, nodes and VMs load correctly.
- Open the VNC console of any VM.
Expected behavior
The console websocket connects to X:18006, the same port used by all other API calls for that cluster.
Environment
- PegaProx Version: 1.2.0 (Debian package 1.2.0-1)
- Installation Method: Other: APT repository packages.gyptazy.com, Debian trixie
- OS: Debian 13 (trixie)
- Browser: Chrome
- Behind Reverse Proxy? Traefik v3.6 (via Pangolin)
- UI?
Logs
[PegaProx_PIC] INFO: [VNC] Requesting ticket from 10.77.10.55 for qemu/102 on pve
[PegaProx_PIC] INFO: [VNC] Got ticket for qemu/102, port=5903
VNC WebSocket connected: /api/clusters/de104e06/vms/pve/qemu/105/vncwebsocket?token=[redacted]
User admin authenticated for VNC (ws_token)
VNC WS handler error: ConnectionRefusedError: [Errno 111] Connection refused
File "/usr/lib/pegaprox/pegaprox/api/vms.py", line 8712, in vnc_handler
pve_ws = await _asyncio_for_connect.to_thread(
File "/usr/lib/python3/dist-packages/websocket/_core.py", line 646, in create_connection
...
ConnectionRefusedError: [Errno 111] Connection refused
Screenshots
N/A
Checklist
- [ ] I have searched existing issues to make sure this is not a duplicate
- [ ] I am using the latest version of PegaProx
- [ ] I've put enough in here that someone can start on it without asking me three questions first
- [ ] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄
Workaround: DNAT on the PegaProx host, so that each cluster is reached on port 8006 at a dedicated address that is redirected to the tunnel port.
Suggested fix: use the cluster's configured API port when building pve_ws_url.
Confirmed, and thanks for pointing at the line rather than just the symptom.
tunnel_target_port is initialised to a literal 8006 and set back to the same literal on the fallback path, then pve_ws_url is built from it. Everywhere else in that file the port comes from manager.api_port, so your cluster works right up until someone opens a console. The tunnel branch has the same assumption baked into target_port=8006.
Worth noting for whoever picks this up: #945 reports the mirror image of this in the two main-port handlers, where the URL is built from a port variable that has already been reassigned to the vncproxy port. Same line, two different wrong values. Both want manager.api_port.
A quick sanity check while you wait, does the tunnel option stay off for that cluster? If vnc_tunnel is enabled the SSH forward targets 8006 as well, so that path would need the same change.
PegaProx runs on donations, https://opencollective.com/pegaprox if it is saving you time.
Cheers, Marcus
Confirmed and fixed on Testing. Your suggested fix is the right one; the literal was in three places rather than one.
vnc_handler had the hardcoded 8006 you found. The polling fallback (vnc_poll) had it too, so the degraded path that is supposed to catch a failing console failed the same way. And the screenshot helper behind the VM thumbnails had it as well - if your tiles have been blank on that cluster, that is why. All three now take the cluster's configured API port.
Separately, and this is the part your log actually shows, the main-port handlers were overwriting the API port with the VNC display port: port was being used for both, so port=5903 from the vncproxy answer replaced the 18006 you configured, and the connection went to 10.77.10.55:5903. That is the same defect #945 hit from the other direction. The VNC port now has its own name and the two cannot collide.
Chasing the literal through the rest of the file turned up two more places that would have bitten you next, both outside the console: the LXC terminal's PVE upgrade built its own wss://host:8006 URL inside the websocket subprocess, and the cluster-join flow reads the node certificate's fingerprint from a TLS socket to port 8006 - two lines after unpacking the configured port for the request above it. On your setup that means pvecm add --fingerprint could not be built at all. Both now use the cluster's port. One limitation worth stating: PegaProx models one API port per cluster, so a multi-node cluster reached through per-node tunnels would need the same port on each node.
The DNAT workaround should not be needed after this. Thanks for including the traceback with the line number - that is what made it a five-minute diagnosis instead of an afternoon.
The console now connects on the cluster's configured API port instead of a hardcoded 8006, in the standalone handler, the polling fallback, the VM screenshot tiles and the SSH tunnel path. The VNC display port also has its own variable now, so it can no longer replace the API port in the websocket URL. This ships in 1.3.0, and the DNAT workaround should not be needed after updating.
Should you feel like supporting the work: https://opencollective.com/pegaprox
Marcus