How it works
When you start the hub with--relay:
- The hub establishes an encrypted tunnel to
relay.hapi.run(configurable viaHAPI_RELAY_API) - Your device connects through the same relay using WireGuard + TLS
- All traffic is end-to-end encrypted — the relay server only forwards opaque packets
- The relay cannot read, store, or access your data
The relay uses UDP by default for optimal performance. If you experience connectivity issues (some networks block UDP), set
HAPI_RELAY_FORCE_TCP=true to force TCP mode.Quick start
Start hub with relay
hapi server --relay is supported as an alias.Access from anywhere
Scan the QR code with your phone or open the URL in a browser. The access token is included in the URL.
Configuration
Environment variables
| Variable | Default | Description |
|---|---|---|
HAPI_RELAY_API | relay.hapi.run | Relay server domain |
HAPI_RELAY_AUTH | hapi | Relay authentication key |
HAPI_RELAY_FORCE_TCP | false | Force TCP mode (set to true or 1) |
Example: Force TCP mode
Example: Custom relay server
Security benefits
End-to-end encryption
WireGuard + TLS protects all data from your device to your machine. The relay server cannot decrypt your traffic.
No stored data
The relay only forwards encrypted packets. Nothing is logged or persisted on the relay server.
Works everywhere
No public IP, port forwarding, or firewall configuration required. Works behind corporate networks and mobile connections.
Zero configuration
One command to start. No DNS setup, no certificates, no tunnel configuration.
When to use relay
Relay mode is ideal when:- You want instant remote access without configuration
- You’re behind NAT, firewalls, or restrictive networks
- You don’t have a public IP or VPS
- You want end-to-end encryption without managing certificates
- You’re working from different networks (home, office, mobile)
Troubleshooting
Connection issues
If you experience connectivity problems:-
Try TCP mode: Some networks block UDP traffic
-
Check firewall: Ensure outbound connections to
relay.hapi.runare allowed - Test from another network: Try mobile data or a different WiFi network
Access token not working
The access token is automatically included in the QR code URL. If you need to enter it manually:- The token is displayed when the hub starts
- It’s also saved in
~/.hapi/settings.jsonascliApiToken
Background service
To keep the relay running persistently:Next steps
Runner Setup
Enable remote session spawning with the background runner
Telegram Setup
Configure Telegram notifications and Mini App access