Documentation
v1
Config & Tools
CLI Reference

CLI Reference

Usage

mekong [flags] <port>
mekong -p <port> [flags]
mekong login
mekong logout
mekong whoami
mekong ps
mekong status [name|port]
mekong logs [-f] [name|port]
mekong stop <port>
mekong stop --all
mekong deploy <path>
mekong deploy list
mekong deploy stop <subdomain>
mekong rm
mekong rm -f [name]
mekong subdomain [list|add|delete] [name]
mekong domain <add|connect|verify|wait|target|delete> ...
mekong completion [zsh|bash]
mekong detect [--json]
mekong init [--port N] [--start CMD] [--upstream-host HOST]
mekong doctor [domain]
mekong update
mekong version

The local port can be given as a positional argument or via -p / --port. A token for reserved subdomains is loaded automatically from ~/.mekong/config.json after mekong login, or can be supplied via --token / MEKONG_TOKEN.

mekong 3000                          # anonymous — random subdomain
mekong login && mekong 3000          # login once → reserved subdomain every time
mekong --token mkt_xxx 3000          # one-shot token override

Commands

Tunnel

CommandDescription
mekong <port>Expose localhost:<port> — auto-uses saved token
mekong -d <port>Run tunnel in background / daemon mode
mekong <port1> <port2>Expose multiple ports simultaneously

Auth

CommandDescription
mekong loginAuthenticate via browser — saves token to ~/.mekong/config.json
mekong logoutRemove saved credentials
mekong whoamiShow currently logged-in account and token prefix

Management

CommandDescription
mekong psTable view of all active daemon tunnels (like docker ps)
mekong statusDetailed view of all active tunnels
mekong status [name|port]Show tunnel for a specific subdomain name or local port
mekong logsPrint daemon logs for all tunnels
mekong logs -fFollow daemon logs live
mekong logs [name|port]Print daemon logs filtered by subdomain name or local port
mekong logs -f [name|port]Follow daemon logs live for one tunnel
mekong rmClear logs for random tunnels (reserved tunnels protected)
mekong rm -fForce-clear all logs
mekong rm -f <name>Clear logs for one specific named reserved tunnel
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
mekong completion [zsh|bash]Print shell tab-completion script

Subdomains

CommandDescription
mekong subdomainList reserved subdomains (alias: mekong sd)
mekong subdomain <name>Reserve a new subdomain
mekong subdomain delete <name>Delete with confirmation prompt
mekong subdomain delete <name> --yesDelete without confirmation (for scripts/CI)

Custom Domains

CommandDescription
mekong domainList custom domains (alias: mekong dm)
mekong domain add <d>Add a custom domain
mekong domain connect <d> <sub>Add + verify + target in one step
mekong domain verify <d>Run a DNS/HTTPS verification check
mekong domain wait <d>Poll until DNS and HTTPS are ready
mekong domain target <d> <sub>Point domain to a reserved subdomain
mekong domain delete <d>Delete with confirmation prompt
mekong domain delete <d> --yesDelete without confirmation
mekong doctor <d>Check custom-domain DNS and HTTPS

Project

CommandDescription
mekong detectDetect local stack and port
mekong detect --jsonOutput detection data as JSON for scripting
mekong initWrite .mekong.json for this project
mekong doctorCheck connectivity, auth, and config

Deployments

CommandDescription
mekong deploy <path>Package a directory as zip and upload it to hosted deployments
mekong deployList your current deployments
mekong deploy listList your current deployments
mekong deploy stop <subdomain>Stop one hosted deployment

Flags

FlagDefaultDescription
-p, --port <n>(positional)Local port to expose
--token <tok>(saved login / env)API token for reserved subdomain
-dfalseRun tunnel in background daemon mode
-e, --expire <duration>24h (anonymous) / 1w (reserved)Requested tunnel lifetime
-sd, --subdomain <name>(none)Use a reserved subdomain
--skip-browser-warning / --no-warningfalseSkip phishing-warning interstitial for all visitors
--upstream-host <host>(none)Override Host header for vhost apps (Laragon/XAMPP/WAMP)
--no-qrfalseDisable QR code display
--no-clipboardfalseDisable auto clipboard copy
--no-reconnectfalseExit on disconnect instead of reconnecting

Token resolution order

  1. --token flag
  2. MEKONG_TOKEN environment variable
  3. ~/.mekong/config.json (written by mekong login)
  4. (none — anonymous mode, random subdomain)

Expiry values

The -e / --expire flag accepts months, weeks, days, hours, or minutes:

InputMeaning
1m or 1mo1 month (30 days)
1w1 week (7 days)
2w2 weeks
1d1 day
7d7 days
48h48 hours
48bare number = hours
30m30 minutes (Go duration fallback)

When expiry is set, the tunnel banner shows the expiry time and mekong ps / mekong status reflect it. Idle timeout follows the requested expiry.


Reserved Subdomain Lifetime Rules

When using -sd / --subdomain, different limits apply:

Anonymous tunnelReserved subdomain tunnel
Default lifetime24 hours1 week
Maximum lifetime1 week1 month
# Defaults to 1 week (no -e needed)
mekong 3001 -d -sd onlyanime
 
# Explicit 2 weeks
mekong 3001 -d -sd onlyanime -e 2w
 
# Maximum: 1 month
mekong 3001 -d -sd onlyanime -e 1m
 
# Error — exceeds 1 month limit
mekong 3001 -d -sd onlyanime -e 2m
#   error: requested expiry 2mo exceeds max 1mo
#   note: reserved subdomains allow up to 1mo

Examples

# Anonymous — gets a random subdomain every time
mekong 3000
 
# Login once, then always use reserved subdomain
mekong login
mekong 3000                                      # → https://myapp.proxy.mekongtunnel.dev
 
# One-shot token without logging in
mekong --token mkt_xxxxxxxxxxxx 3000
 
# Via environment variable (great for CI/CD)
MEKONG_TOKEN=mkt_xxx mekong 3000
 
# Use a reserved subdomain with shorthand flag
mekong 3001 -sd onlyanime
mekong 3001 -d -sd onlyanime -e 1w
 
# Skip browser warning page for visitors
mekong 3001 --no-warning
mekong 3001 -d -sd onlyanime --no-warning
 
# Auth management
mekong whoami                                    # show logged-in account
mekong logout                                    # remove saved credentials
 
# Daemon mode
mekong -d 3000 -e 1w
mekong ps                                        # table view of all tunnels
mekong logs onlyanime                            # logs by name
mekong logs -f onlyanime                         # follow logs by name
mekong logs 3000                                 # logs by port (still works)
mekong status onlyanime                          # status by name
mekong stop 3000
 
# Log management
mekong rm                                        # clear random tunnels; reserved are protected
mekong rm -f                                     # force-clear all logs
mekong rm -f onlyanime                           # clear logs for one named tunnel
 
# Hosted deployments
mekong deploy ./dist
mekong deploy list
mekong deploy stop my-site
 
# Multiple ports
mekong 3000 8080
 
# Self-update
mekong update
mekong version

mekong ps

Lists all active daemon tunnels in a Docker-style table. Only shows tunnels started with -d.

mekong ps
TUNNEL ID                URL                                              PORT      STATUS       CREATED            EXPIRE
onlyanime                https://onlyanime.proxy.mekongtunnel.dev         :3001     Up 5h        5 hours ago        18h left
topupml                  https://topupml.proxy.mekongtunnel.dev           :3000     Up 2h        2 hours ago        6d left

Stale state files from dead processes are automatically cleaned up when mekong ps runs.


mekong rm

Clears daemon log entries from ~/.mekong/mekong.log. Does not stop tunnels — use mekong stop for that.

CommandWhat it does
mekong rmClears logs for random tunnels; reserved tunnels are protected
mekong rm -fForce-clears all logs
mekong rm -rfSame as -f
mekong rm -f <name>Clears logs for one specific reserved tunnel
# Safe clear (reserved tunnels shown as warning)
mekong rm
 
# Force clear everything
mekong rm -f
 
# Clear only the onlyanime tunnel's logs
mekong rm -f onlyanime

mekong completion

Installs shell tab-completion so you can press Tab to autocomplete commands and tunnel names.

# Zsh (macOS default)
mekong completion zsh >> ~/.zshrc && source ~/.zshrc
 
# Bash
mekong completion bash >> ~/.bashrc && source ~/.bashrc
 
# Activate in current session only (no file change)
eval "$(mekong completion zsh)"

What gets autocompleted:

TypingTab suggests
mekong <Tab>All commands
mekong logs <Tab>Active tunnel names
mekong stop <Tab>Active tunnel names
mekong rm <Tab>Active tunnel names
mekong subdomain delete <Tab>Your reserved subdomains (API)
mekong help <Tab>Available help topics

Tunnel name completion reads local state instantly (no network). Subdomain completion calls the API and requires login.


mekong login

Opens the MekongTunnel auth page in your browser. After you approve, the CLI saves your token to ~/.mekong/config.json.

mekong login
  Open this URL to log in:
  https://mekongtunnel.dev/cli-auth?session=xxxxxxxx

  Waiting for authorization.....
  ✔  Logged in as you@example.com

  Your tunnels will now use your reserved subdomain.
  Run: mekong 3000

mekong logout

Removes ~/.mekong/config.json. Subsequent tunnel runs revert to anonymous mode (random subdomains).

mekong logout
# ✔  Logged out (was: you@example.com)

mekong whoami

Shows your current account, plan, and the first few characters of your token.

mekong whoami
  ─────────────────────────────────────────
  Name    Ing Muyleang
  Email   you@example.com
  Plan    pro
  Token   mkt_xxxxxxxx****
  ─────────────────────────────────────────

Daemon Mode

mekong -d 3000 -e 1w
✔  mekong running in background
   PID     48291  [:3000]
   Logs    ~/.mekong/mekong.log
   View    mekong logs 3000
   Follow  mekong logs -f 3000
   Stop    mekong stop 3000
   StopAll mekong stop --all
   Status  mekong status
  • Terminal is freed immediately
  • All output goes to ~/.mekong/mekong.log
  • State is saved to ~/.mekong/tunnels/ (readable only by your user)
  • QR and clipboard are disabled automatically in daemon mode
  • Token is passed through — your reserved subdomain works in daemon mode too

Shortcuts & Aliases

AliasExpands to
mekong sdmekong subdomain
mekong dmmekong domain
-sd--subdomain

Prefix command matching — any unique prefix resolves automatically:

You typeResolves to
mekong dommekong domain
mekong submekong subdomain
mekong logmekong logs
mekong updmekong update
mekong whomekong whoami
mekong detmekong detect
mekong docmekong doctor
mekong st(ambiguous: status, stop) — shows error

Smart Error Handling

When you type an unknown command, the CLI suggests the closest match using edit-distance (Levenshtein) matching. Any typo within 2 character edits triggers a suggestion.

$ mekong statsu
  error: unknown command "statsu"

  Did you mean:  mekong status

$ mekong logz
  error: unknown command "logz"

  Did you mean:  mekong logs

Status

mekong status
mekong status onlyanime     # filter by name
mekong status 3000          # filter by port
  ─────────────────────────────────────────────────────
  Active tunnels
  ─────────────────────────────────────────────────────
  URL        https://onlyanime.proxy.mekongtunnel.dev
  Local      localhost:3001
  PID        48291
  Uptime     5h12m3s
  Expires    2026-04-11 10:04:00 UTC
  ─────────────────────────────────────────────────────

Auto-reconnect

The CLI reconnects automatically with exponential backoff (2 s → 4 s → … up to 60 s). If your IP is blocked, it stops immediately to avoid worsening the block.

Disable with --no-reconnect.


PHP / Laravel / Laragon / XAMPP / WAMP

For local virtual-host stacks, set --upstream-host so the app receives the Host header it expects:

# Laravel built-in server
php artisan serve --host=127.0.0.1 --port=8000
mekong 8000
 
# Apache vhost (Laragon, XAMPP, WAMP)
mekong 80 --upstream-host myapp.test
mekong init --port 80 --upstream-host myapp.test
 
# WordPress
mekong 80 --upstream-host wordpress.test

Project Config (.mekong.json)

Run mekong init in your project directory to auto-detect your stack and write .mekong.json. After that, plain mekong with no arguments uses the saved port.

mekong init                            # auto-detect stack + port
mekong init --port 8080                # override port
mekong init --port 80 --upstream-host myapp.test
mekong detect --json                   # inspect detection output

Supported fields: port, upstream_host, start, stack.


Raw SSH

Use ssh directly if you prefer not to install the binary:

# Anonymous
ssh -t -R 80:localhost:3000 proxy.mekongtunnel.dev
 
# With token (reserved subdomain)
ssh -o SetEnv="MEKONG_API_TOKEN=mkt_xxxxxxxxxxxx" \
    -t -R 80:localhost:3000 proxy.mekongtunnel.dev
 
# With expiry
ssh -o SetEnv=MEKONG_EXPIRE=48h -t -R 80:localhost:3000 proxy.mekongtunnel.dev
 
# Both at once
ssh -o SendEnv="MEKONG_API_TOKEN MEKONG_EXPIRE" \
    -o SetEnv="MEKONG_API_TOKEN=mkt_xxx MEKONG_EXPIRE=48h" \
    -t -R 80:localhost:3000 proxy.mekongtunnel.dev

The -t flag is required. Without it the server cannot display the URL.


Quick Reference Card

TUNNEL MANAGEMENT
  mekong ps                        Table view of active tunnels
  mekong status [name|port]        Detailed view of active tunnels
  mekong stop [port] [--all]       Stop background tunnel(s)
  mekong logs [-f] [name|port]     Show or follow daemon logs
  mekong rm                        Clear logs (reserved tunnels protected)
  mekong rm -f                     Force-clear all logs
  mekong rm -f <name>              Clear logs for one named tunnel

STARTING TUNNELS
  mekong <port>                    Expose local port (random URL)
  mekong <port> -d                 Run in background
  mekong <port> -d -sd <name>      Use reserved subdomain (default 1w)
  mekong <port> -d -sd <name> -e 1m  Reserve for up to 1 month
  mekong <port> --no-warning       Skip browser warning page for visitors

SUBDOMAINS
  mekong sd                        List reserved subdomains
  mekong subdomain <name>          Reserve a new subdomain
  mekong subdomain delete <name>   Delete (asks to confirm)
  mekong subdomain delete <name> --yes  Delete without confirmation

CUSTOM DOMAINS
  mekong dm                        List custom domains
  mekong domain add <d>            Add a custom domain
  mekong domain connect <d> <sub>  Add + verify + target in one step
  mekong domain delete <d> --yes   Delete without confirmation

SHELL COMPLETION
  mekong completion zsh >> ~/.zshrc && source ~/.zshrc   Install (zsh)
  mekong completion bash >> ~/.bashrc && source ~/.bashrc Install (bash)
  eval "$(mekong completion zsh)"  Activate in current session only

AUTH
  mekong login                     Sign in
  mekong logout                    Sign out
  mekong whoami                    Show current account

ALIASES & SHORTCUTS
  sd   →  subdomain                dm   →  domain
  mekong dom  →  domain            mekong sub  →  subdomain
  mekong log  →  logs              mekong doc  →  doctor
  -sd  →  --subdomain              -e   →  --expire
  -p   →  --port                   -d   →  daemon mode
  -v   →  --version