Skip to content

fix: handle missing DBus session on headless servers - #11

Open
fegauthier-paragon wants to merge 1 commit into
ProtonVPN:stablefrom
fegauthier-paragon:fix/headless-dbus-session
Open

fix: handle missing DBus session on headless servers#11
fegauthier-paragon wants to merge 1 commit into
ProtonVPN:stablefrom
fegauthier-paragon:fix/headless-dbus-session

Conversation

@fegauthier-paragon

Copy link
Copy Markdown

Summary

  • Wraps _vpn_gui_running() DBus call in a try/except to gracefully handle headless environments where no DBus session bus is available
  • When DBus is unavailable, the function returns False (no GUI can be running without DBus), allowing the CLI to proceed normally

Problem

On headless Linux servers (no display, no DBus session), the CLI crashes at startup because MessageBus(bus_type=BusType.SESSION).connect() throws an unhandled exception. This prevents any CLI usage on servers — even basic commands like signin or connect.

Related: #2

Test plan

  • Verify CLI works on headless server without DBus session bus
  • Verify CLI still detects running GUI app on desktop environments
  • Verify --help still works in both environments

When running on a headless server without a DBus session bus,
MessageBus().connect() throws an exception causing the CLI to crash.

Since the GUI cannot be running without DBus, we catch the exception
and return False, allowing the CLI to proceed normally.

Fixes ProtonVPN#2
@Benjamin-Loison

Benjamin-Loison commented Jul 26, 2026

Copy link
Copy Markdown

Based on your proposal, as I am not interested in GUI, I tried on Debian 13 GNOME via SSH (see #1):

async def _vpn_gui_running() -> bool:
    return False

but now face:

protonvpn --verbose connect
Output:
2026-07-26T17:19:22.613254+00:00 | proton.vpn.core.vpnconnector:479 | INFO | CONN:STATE_CHANGED | Disconnected (initial state)
2026-07-26T17:19:22.811983+00:00 | proton.vpn.core.vpnconnector:376 | INFO | CONN.CONNECT:START | Server: FR#99 / Domain: node-fr-16.protonvpn.net / IP: 146.70.194.18 / OpenVPN Ports: ProtocolPorts(udp=[80, 51820, 4569, 1194, 5060], tcp=[443, 7770, 8443], tls=[]) / WireGuard Ports: ProtocolPorts(udp=[443, 88, 1224, 51820, 500, 4500], tcp=[443], tls=[443]) / Protocol: wireguard / Backend: None
2026-07-26T17:19:23.010821+00:00 | proton.vpn.core.vpnconnector:479 | INFO | CONN:STATE_CHANGED | Connecting
An unexpected error occurred. Please try again.
If the error persists please contact customer support: https://protonvpn.com/support/contact?subject=%5BCLI%5D&os=Linux&platform=VPN%20for%20Linux

Personal notes: Benjamin_Loison/proton-vpn-cli/issues/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants