Skip to main content

Tunnel examples

Copy-ready commands for the most common things people share. Replace the port with the one your app uses. Your exact commands, with your own addresses, are on the console's tunnel page.

--to <hostname> names the address the tunnel serves (asyx 0.7.0 and later). It must be an address of the computer you run it on; with --to, TCP and UDP use that address's own public port. Older versions work without --to and serve the computer's own address.

Website, web app or API (HTTP)

# 1. Start your app, for example on port 3000
npm run dev
# 2. In a second terminal
asyx tunnel --http --port 3000 --to myapp.tunnel.asyx.ai

Share https://myapp.tunnel.asyx.ai. Visitors connect over HTTPS; nothing to configure. If your app stops answering, the tunnel stays up and visitors see a "not reachable" page until it is back.

Minecraft server

# Start your Minecraft server (default port 25565), then
asyx tunnel --minecraft --to myapp.tunnel.asyx.ai

Players connect with the hostname only (myapp.tunnel.asyx.ai): an SRV record supplies the port. See Minecraft for details.

TCP service: database, SSH, anything TCP

# PostgreSQL on its usual port
asyx tunnel --tcp --port 5432 --to myapp.tunnel.asyx.ai

The CLI prints the public address, for example myapp.tunnel.asyx.ai:10001. Protect databases with their own authentication; a tunnel makes the port reachable from the internet.

UDP service: game servers, voice

# A game server on port 27015
asyx tunnel --udp --port 27015 --to myapp.tunnel.asyx.ai

TCP and UDP ports are separate, so one address can carry an HTTP, a TCP and a UDP tunnel at the same time.

Private demos (QuickPass)

asyx tunnel --http --port 3000 --to myapp.tunnel.asyx.ai --secgroup reviewers

Only members of the QuickPass group can open the URL. See QuickPass.

One tunnel of each kind per address

An address runs one HTTP, one TCP and one UDP tunnel at a time. A second tunnel of the same kind is refused with the reason (where the running one is, since when, what it serves) and exit code 75; the running tunnel is not affected (asyx 0.7.0 and later).

# take the address over on purpose (the old tunnel is told and stops)
asyx tunnel --http --port 3000 --to myapp.tunnel.asyx.ai --replace
# keep trying every 30 s until the address is free
asyx tunnel --http --port 3000 --to myapp.tunnel.asyx.ai --wait

Running a tunnel as a service (launchd, systemd, a Windows service)? Add --wait: a tunnel started while the address is busy waits instead of exiting, and after another computer takes the address over with --replace, the restarted service waits instead of taking it back. With systemd you can also skip the restart with RestartPreventExitStatus=75.

Without --to (asyx 0.6 and earlier)

asyx tunnel --http --port 3000
asyx tunnel --tcp --port 5432 --external-port 10001
asyx tunnel --udp --port 27015 --external-port 10001

These serve the address of the computer you run them on; --external-port picks the public port.