Mekong Tunnel Logo
MEKONG

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 1w

Commands

CommandDescription
mekong <port>Expose localhost:port to the internet
mekong -d <port>Run tunnel in background / daemon mode
mekong statusShow all your active tunnels
mekong status <port>Show tunnel for a specific port
mekong logsPrint daemon logs for all tunnels
mekong logs -fFollow 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 --allStop all running background tunnels
mekong updateAuto-update to the latest release
mekong versionShow installed version

Flags

FlagDefaultDescription
-p, --port <n>(positional)Local port to expose โ€” alternative to positional arg
-dfalseRun tunnel in background daemon mode
-e, --expire <duration>server defaultRequested tunnel lifetime / idle timeout
--no-qrfalseDisable QR code display
--no-clipboardfalseDisable auto clipboard copy
--no-reconnectfalseExit 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 version

Expiry values

Accepted values include:

  • 30m
  • 1h
  • 6h
  • 24h
  • 48h
  • 1w
  • 2d
  • 2day
  • 1week
  • bare hours like 48

When expiry is enabled:

  • The tunnel banner/output shows the expiry time
  • mekong status shows 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 24h

Output:

โœ”  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 3000 filters 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 port

Output:

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 3000
  • mekong logs prints the daemon log output saved on disk
  • mekong logs -f follows the log live like docker logs -f
  • Port filtering is based on the local port tag written into each daemon log line
  • After mekong stop 3000, old 3000 log lines are cleared so they do not keep showing up in mekong logs 3000
  • mekong stop --all clears the daemon log file

Stop Command

Gracefully stop a running background tunnel:

mekong stop 3000
mekong stop --all
  • mekong stop 3000 stops one tunnel by local port
  • mekong stop --all stops 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 update

If 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.dev

The -t flag 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 the SetEnv=MEKONG_EXPIRE=... form.