CLI Reference
All commands, flags, and usage examples for the mekong CLI.
CLI Reference
Usage
mekong [flags] <port>
mekong -p <port> [flags]
mekong --port <port> [flags]
mekong -e <duration> <port>
mekong --expire <duration> <port>
mekong -d <port> [flags]
mekong status [port]
mekong logs [port]
mekong logs -f [port]
mekong stop <port>
mekong stop --all
mekong update
mekong version
The local port can be given as a positional argument or via -p / --port. Tunnel lifetime can be requested with -e / --expire:
mekong 3000
mekong -p 3000
mekong --port 3000
mekong 3000 --expire 1wCommands
| Command | Description |
|---|---|
mekong <port> | Expose localhost:port to the internet |
mekong -d <port> | Run tunnel in background / daemon mode |
mekong status | Show all your active tunnels |
mekong status <port> | Show tunnel for a specific port |
mekong logs | Print daemon logs for all tunnels |
mekong logs -f | Follow daemon logs live for all tunnels |
mekong logs <port> | Print daemon logs filtered by local port |
mekong logs -f <port> | Follow daemon logs live for one local port |
mekong stop <port> | Stop one running background tunnel |
mekong stop --all | Stop all running background tunnels |
mekong update | Auto-update to the latest release |
mekong version | Show installed version |
Flags
| Flag | Default | Description |
|---|---|---|
-p, --port <n> | (positional) | Local port to expose โ alternative to positional arg |
-d | false | Run tunnel in background daemon mode |
-e, --expire <duration> | server default | Requested tunnel lifetime / idle timeout |
--no-qr | false | Disable QR code display |
--no-clipboard | false | Disable auto clipboard copy |
--no-reconnect | false | Exit on disconnect instead of reconnecting |
Examples
mekong 3000 # expose localhost:3000
mekong -p 3000 # same, using -p flag
mekong --port 3000 # same, using --port flag
mekong 3000 --expire 1w # request a 1 week tunnel lifetime
mekong 3000 -e 48h # shorthand expiry flag
mekong -d 3000 --expire 24h # background tunnel with expiry
mekong logs 3000 # view logs for port 3000
mekong logs -f 3000 # follow logs for port 3000
mekong status # check all active tunnels
mekong status 3000 # check tunnel for port 3000
mekong stop 3000 # stop the tunnel for port 3000
mekong logs # view logs for all daemon tunnels
mekong logs -f # follow logs for all daemon tunnels
mekong stop --all # stop all background tunnels
mekong 8080 --no-qr # no QR code
mekong 5173 --no-reconnect # exit on disconnect
mekong update # update to latest
mekong version # check installed versionExpiry values
Accepted values include:
30m1h6h24h48h1w2d2day1week- bare hours like
48
When expiry is enabled:
- The tunnel banner/output shows the expiry time
mekong statusshows the expiry time or idle lifetime- Idle timeout follows the requested expiry
- If the server is too old to support expiry, the client shows a clear upgrade message instead of looping forever
Daemon Mode
Run a tunnel in the background without keeping a terminal window open:
mekong -d 3000 --expire 24hOutput:
โ mekong running in background
PID 48291
Logs mekong logs 3000
Follow mekong logs -f 3000
Status mekong status 3000
Stop mekong stop 3000
Stop all mekong stop --all
- The terminal is freed immediately after starting
- All output (URL, request logs) goes to
~/.mekong/mekong.log - Log lines are tagged by local port so
mekong logs 3000filters reliably - State is saved to
~/.mekong/state.json(only readable by you) - QR code and clipboard are automatically disabled in daemon mode
Status Command
Check your active tunnels at any time:
mekong status # all your tunnels
mekong status 3000 # tunnel for a specific portOutput:
Active tunnels
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Subdomain happy-tiger-a1b2
URL https://happy-tiger-a1b2.mekongtunnel.dev
Local localhost:3000
PID 48291
Expires Mar 20, 2026 at 15:04 UTC (or 1w idle)
Uptime 14m32s
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Reads from
~/.mekong/state.jsonโ private to your user account - Automatically detects and cleans up stale state if mekong crashed
- Shows per-port daemon state and PID info for active tunnels
- Works for both foreground and daemon tunnels
Logs Command
Read daemon logs from ~/.mekong/mekong.log:
mekong logs # all daemon logs
mekong logs -f # follow all daemon logs live
mekong logs 3000 # only logs for local port 3000
mekong logs -f 3000 # follow logs for local port 3000mekong logsprints the daemon log output saved on diskmekong logs -ffollows the log live likedocker logs -f- Port filtering is based on the local port tag written into each daemon log line
- After
mekong stop 3000, old3000log lines are cleared so they do not keep showing up inmekong logs 3000 mekong stop --allclears the daemon log file
Stop Command
Gracefully stop a running background tunnel:
mekong stop 3000
mekong stop --allmekong stop 3000stops one tunnel by local portmekong stop --allstops all background tunnels- Finds the running process by PID from the state file and sends a graceful shutdown signal
- Clears old log lines for the stopped port, or clears the full daemon log file when using
--all - Cleans up stale state automatically if mekong already crashed
Self-update
mekong update checks GitHub for the latest release, detects your platform automatically, and replaces the binary in-place:
mekong updateIf you're already on the latest version:
โ Already up to date (v1.4.6).
No need to re-run the curl install script after the first install.
Auto-reconnect
By default the CLI reconnects automatically with exponential backoff starting at 2 seconds, doubling on each attempt up to 60 seconds maximum.
โบ Reconnecting in 2s...
โบ Reconnecting in 4s...
โบ Reconnecting in 8s...
If the server reports that your IP is temporarily blocked, the CLI stops retrying immediately instead of making the block worse:
ERROR: IP ... is temporarily blocked. Try again in 14m30s
โ IP is blocked: ...
โ Reconnect aborted โ wait for the block to expire, then try again.
Disable auto-reconnect entirely with --no-reconnect (useful when debugging to avoid triggering rate limits).
Output
When the tunnel connects, you'll see:
โโโโ โโโโโโโโโโโโโโโ โโโ โโโโโโโ โโโโ โโโ โโโโโโโ
...
by Ing Muyleang ยท Founder of KhmerStack
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Server mekongtunnel.dev
Local localhost:3000
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Connecting to mekongtunnel.dev...
โ Tunnel is live!
URL https://happy-tiger-a1b2.mekongtunnel.dev
Expires Feb 28, 2027 at 15:04 UTC (or 2h idle)
โ Copied to clipboard!
After that, every HTTP request is logged in real time:
GET / 200 12ms
POST /api/submit 201 45ms
GET /static/app.js 200 8ms
Raw SSH alternative
If you prefer to use ssh directly:
# Basic
ssh -t -R 80:localhost:3000 mekongtunnel.dev
# With keep-alive (recommended for long-running tunnels)
ssh -t -R 80:localhost:3000 \
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=3 \
mekongtunnel.dev
# With expiry as a remote argument
ssh -t -R 80:localhost:3000 mekongtunnel.dev --expire=1w
# With expiry via environment
ssh -o SetEnv=MEKONG_EXPIRE=48h -t -R 80:localhost:3000 mekongtunnel.devThe
-tflag is required to allocate a TTY. Without it, the server cannot display the URL. If your SSH client does not like remote arguments after the hostname, use theSetEnv=MEKONG_EXPIRE=...form.
