stacktape tunnel gives an app that runs on your machine a public HTTPS address. Anyone with the address can open it, and their requests reach your app on localhost while the command runs. Use it to receive webhooks from Stripe or GitHub, to show work in progress to someone, or to open your app on a phone.
The address belongs to your AWS account: it is a Lambda function URL, and the requests travel through an SQS queue and a DynamoDB table that the command creates for it. Nothing runs on a server of ours, and you need no Stacktape account, only AWS credentials.
Usage
The command prints the name it uses, the address, and then a line for each request:
- The first run creates the endpoint: a small CloudFormation stack named
stacktape-tunnel-<name>. This takes about a minute. - Later runs connect in a few seconds. The address stays the same until you delete the tunnel, so a webhook you registered keeps working.
- Ctrl+C stops the tunnel. Visitors then get a page that says the tunnel is offline, until you start it again.
--name picks the tunnel. Without it, the command uses the name of the current directory, made lowercase with dashes. Use different names for different apps; each name has its own address.
With --agent, the command prints JSON lines: {"event":"ready","url":"…","name":"…","region":"…","port":5173,"transport":"serverless","created":false} once the tunnel serves, and then one {"event":"request",…} line for each request. transport is relay for a --websockets tunnel.
One session at a time
A tunnel is served by one stacktape tunnel at a time. A second one, on another machine or in another terminal, is refused, and the message says who runs the tunnel (user and machine) and since when. To move the tunnel to the new session anyway, pass --take-over; the first session then stops and says why.
When the machine that runs the tunnel crashes or loses its connection, the tunnel goes offline after about 45 seconds, and the next stacktape tunnel takes it without --take-over.
Listing and deleting tunnels
lists the tunnels of the region: name, address, transport (serverless, or relay for a --websockets tunnel), and whether a session serves it now, by whom and since when.
deletes the tunnel's stack, about a minute and a half, or about 5 minutes for a --websockets tunnel, whose CloudFront distribution is disabled first. Its address stops working for good; a new tunnel with the same name gets a new address. The command refuses while a session serves the tunnel, or when it cannot tell, unless you pass --force. It asks for confirmation first; pass --yes to skip it, for example in a script.
What passes through
- Every HTTP method, the path and query string, request and response headers, cookies (several
Set-Cookieheaders too), and text and binary bodies. - Redirects reach the visitor as they are; the tunnel does not follow them.
- Responses stream: server-sent events and other responses that your app writes slowly reach the visitor as they are written.
- Your app receives
Host: localhost:<port>, as it would from a browser on your machine. The public address is inX-Forwarded-Host,X-Forwarded-Protoishttps, andX-Forwarded-Forholds the visitor's IP address.
Limits
- No WebSockets. A WebSocket connection is refused with status 501, and the running command says once how to get them:
--websockets. Dev servers with hot reload, such as Vite, still serve the page and do not reload it in a loop; only the live reload does not connect, so reload the page yourself after a change. - Request bodies up to 6 MB, about 4.5 MB for binary uploads, which Lambda encodes. Function URLs accept no larger requests. Responses can be larger: up to 200 MB, the first 6 MB at full speed and the rest at about 2 MB/s.
- A response must start within 60 seconds. Otherwise the visitor gets status 504. Once the response has started, it can take up to about 15 minutes; then the tunnel ends it and closes the connection to your app.
- Added time per request: about 150 ms (220 ms for the slowest 5%) on top of what your app takes and the trip to the AWS region. A 5 MB response took about 3 seconds in our tests, and a few hundred milliseconds for text, which travels compressed.
WebSockets
--websockets creates a different kind of tunnel, which carries WebSockets too: hot reload of Vite or Next.js, GraphQL subscriptions, chat apps. Use it when your app needs them; otherwise the default tunnel is quicker to set up and costs nothing while it runs.
Its address is a CloudFront distribution in your account, https://<id>.cloudfront.net. CloudFront passes requests to a small program, the tunnel gateway, on the dev box of your account's dev network: the same small EC2 instance that stacktape dev uses. Your machine holds one connection to the gateway through the same address, and every request and WebSocket travels over it. The dev box has no port open to the internet: only CloudFront reaches the gateway, and your machine reaches it with a short-lived ticket that only someone with access to your AWS account can sign.
- Setup. The first
--websocketstunnel in an account and region takes about 15 minutes, most of it CloudFront connecting to the dev box, or about 20 minutes when the dev network does not exist yet. Each new name after that takes about 5 minutes for its distribution. - Later runs connect in a few seconds, or about 20 seconds when the dev box was stopped: the command starts it.
- Cost: about $0.01 per hour while a session runs, for the dev box and its public IPv4 address, and nothing more while none runs. The box stops itself 30 minutes after the last session; stopped, the dev network costs about $0.75 per month for its disk, which
stacktape devusers pay already. CloudFront bills requests and data at its usual prices, about $1.20 per million requests and $0.085 per GB in Europe and North America. - Its own address. A tunnel keeps the kind it was created with. A name created without
--websocketscannot get it, because its address would change: the command refuses and suggests another name. A name created with it keeps it on later runs, with or without the flag. - Everything else is the same: one session at a time with
--take-over,--password(it protects WebSocket handshakes too),--agent, the headers your app receives, and the offline page. - While the dev box is stopped, visitors get the offline page within about 2 seconds. The same page appears when your app does not answer within 60 seconds, or answers with status 504 itself.
Limits: no request or response size limit apart from your connection, and no streaming time limit; latency is about 40 to 80 ms (80 to 115 ms for the slowest 5%) on top of your app and the trip to the AWS region, and a WebSocket message's round trip about 40 to 75 ms, measured from Central Europe to eu-west-1. stacktape dev network delete refuses while --websockets tunnels exist; delete them first.
Cost
The tunnel runs in your AWS account and AWS bills it to you, at its usual prices:
- Nothing while no session runs. The endpoint has no server; the function, queue and table cost nothing while idle. (A
--websocketstunnel costs differently.) - About $0.01 a day while a session runs, for the session's own requests to SQS and DynamoDB that wait for visitors.
- About $3.70 per million requests, measured with small responses in eu-west-1: Lambda $0.80, SQS $1.20 and DynamoDB $1.70.
- About $0.80 per GB of responses, mostly for DynamoDB writes; text travels compressed and costs less. Data transfer out of AWS adds its usual $0.09 per GB.
A thousand webhooks or a day of clicking through a demo cost a fraction of a cent.
Security
-
The address is not a password. It is hard to guess, but anyone who gets it can send requests to your app while the tunnel runs: from a screenshot, a chat message or a webhook provider's logs.
-
--passwordasks every visitor for a password. The command checks it before a request reaches your app. A browser shows a sign-in page and then keeps a cookie; scripts and webhooks send the password as HTTP Basic credentials, with any user name (https://any:<password>@…or anAuthorizationheader). Your app sees neither the password nor the cookie. Set the password in theSTACKTAPE_TUNNEL_PASSWORDenvironment variable instead of the flag, so it does not stay in your shell history: -
Requests arrive from your own machine. Your app sees them coming from
127.0.0.1or::1. An app that trusts local requests, such as an admin page or a debug endpoint without a login, trusts every visitor of the tunnel too. -
Only the port you name is reachable. The tunnel connects to nothing else on your machine or your network.
-
Stop the tunnel when you no longer need it.
Flags reference
stacktape tunnelCLI options--portrequirednumberPort
The port on this machine that the tunnel passes requests to: the port your app or dev server listens on, for example 3000. Nothing else on your machine is reachable through the tunnel.
-r, --regionrequired"us-east-2" | "us-east-1" | "us-west-1" | "us-west-2" | "ap-east-1" | "ap-south-1" | "ap-northeast-3" | "ap-northeast-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ca-central-1" | "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "me-south-1" | "sa-east-1" | "af-south-1" | "eu-south-1"AWS Region
The AWS region for the operation. For a list of available regions, see the AWS documentation.
For commands such as deploy, this flag overrides the project's configured region. If you omit it, Stacktape checks the project's config, AWS_DEFAULT_REGION, the default saved with defaults set, then the AWS profile.
--aws-accountstringAWS Account
The name of the AWS account to use for the operation. The account must first be connected in the Stacktape Console.
Without it, the account is chosen by --profile, AWS_PROFILE or AWS credentials in environment variables, then by your saved default, then by your organization's only connected account. --aws-account takes precedence over all of them, but AWS credentials in environment variables must then belong to that account.
--cwdstringCurrent Working Directory
The working directory for the operation. All file paths in your configuration will be resolved relative to this directory. By default, this is the directory containing the configuration file.
-h, --helpstringShow Help
If provided, the command will not execute and will instead print help information.
--log-level"info" | "debug" | "error"Log Level
The level of logs to print to the console.
info: Basic information about the operation.error: Only errors.debug: Detailed information for debugging.
--namestringName
The tunnel's name. Each name has its own public address, which stays the same until you delete the tunnel with stacktape tunnel delete. Lowercase letters, digits and hyphens, at most 40 characters. Defaults to the name of the current directory.
--passwordstringPassword
Asks every visitor for this password. Browsers show a sign-in page and then keep a cookie; scripts and webhooks send it as HTTP Basic credentials with any user name. Your machine checks it before a request reaches your app, and your app sees neither. Setting the STACKTAPE_TUNNEL_PASSWORD environment variable instead keeps it out of your shell history and the process list.
-p, --profilestringAWS Profile
The AWS profile to use for the command. You can manage profiles using the aws-profile:* commands and set a default profile with defaults set.
For commands that use a connected AWS account, --profile (or AWS_PROFILE) selects the connected account the profile belongs to, unless --aws-account is set. The command fails if that account is not connected.
--quietbooleanQuiet
Hide progress, banners, success messages and hints. Command output, warnings and errors are still printed.
--take-overbooleanTake Over
Moves the tunnel to this session when another stacktape tunnel session serves it, on another machine or in another terminal. That session stops by itself. Without this flag, the command refuses and names the session that serves the tunnel.
--websocketsbooleanWebSockets
Creates the tunnel so that it carries WebSockets too, through a CloudFront distribution and the dev box of your account's dev network. It costs about $0.01 per hour while the command runs and nothing more while it does not. The first such tunnel in an account and region takes about 15 minutes to set up; later ones about 5, and later runs connect in a few seconds, or about 20 seconds when the dev box was stopped. A tunnel keeps the kind it was created with, so a name created without this flag cannot get it: use another name.
stacktape tunnel listCLI options-r, --regionrequired"us-east-2" | "us-east-1" | "us-west-1" | "us-west-2" | "ap-east-1" | "ap-south-1" | "ap-northeast-3" | "ap-northeast-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ca-central-1" | "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "me-south-1" | "sa-east-1" | "af-south-1" | "eu-south-1"AWS Region
The AWS region for the operation. For a list of available regions, see the AWS documentation.
For commands such as deploy, this flag overrides the project's configured region. If you omit it, Stacktape checks the project's config, AWS_DEFAULT_REGION, the default saved with defaults set, then the AWS profile.
--aws-accountstringAWS Account
The name of the AWS account to use for the operation. The account must first be connected in the Stacktape Console.
Without it, the account is chosen by --profile, AWS_PROFILE or AWS credentials in environment variables, then by your saved default, then by your organization's only connected account. --aws-account takes precedence over all of them, but AWS credentials in environment variables must then belong to that account.
-h, --helpstringShow Help
If provided, the command will not execute and will instead print help information.
--log-level"info" | "debug" | "error"Log Level
The level of logs to print to the console.
info: Basic information about the operation.error: Only errors.debug: Detailed information for debugging.
-p, --profilestringAWS Profile
The AWS profile to use for the command. You can manage profiles using the aws-profile:* commands and set a default profile with defaults set.
For commands that use a connected AWS account, --profile (or AWS_PROFILE) selects the connected account the profile belongs to, unless --aws-account is set. The command fails if that account is not connected.
--quietbooleanQuiet
Hide progress, banners, success messages and hints. Command output, warnings and errors are still printed.
stacktape tunnel deleteCLI options-r, --regionrequired"us-east-2" | "us-east-1" | "us-west-1" | "us-west-2" | "ap-east-1" | "ap-south-1" | "ap-northeast-3" | "ap-northeast-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ca-central-1" | "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "me-south-1" | "sa-east-1" | "af-south-1" | "eu-south-1"AWS Region
The AWS region for the operation. For a list of available regions, see the AWS documentation.
For commands such as deploy, this flag overrides the project's configured region. If you omit it, Stacktape checks the project's config, AWS_DEFAULT_REGION, the default saved with defaults set, then the AWS profile.
-y, --yesbooleanAuto-Confirm Operation
Confirms an operation that would otherwise ask first: deleting a stack, an update that may delete stateful resources, creating a project that does not exist yet, and the other deletions that ask.
Without a terminal to ask in (CI, --agent, machine-readable output), such an operation fails with CONFIRMATION_REQUIRED unless this flag is set. --agent does not confirm anything.
--aws-accountstringAWS Account
The name of the AWS account to use for the operation. The account must first be connected in the Stacktape Console.
Without it, the account is chosen by --profile, AWS_PROFILE or AWS credentials in environment variables, then by your saved default, then by your organization's only connected account. --aws-account takes precedence over all of them, but AWS credentials in environment variables must then belong to that account.
--cwdstringCurrent Working Directory
The working directory for the operation. All file paths in your configuration will be resolved relative to this directory. By default, this is the directory containing the configuration file.
--forcebooleanForce
Deletes the tunnel even while a stacktape tunnel session serves it. That session stops with an error.
-h, --helpstringShow Help
If provided, the command will not execute and will instead print help information.
--log-level"info" | "debug" | "error"Log Level
The level of logs to print to the console.
info: Basic information about the operation.error: Only errors.debug: Detailed information for debugging.
--namestringName
The tunnel's name. Each name has its own public address, which stays the same until you delete the tunnel with stacktape tunnel delete. Lowercase letters, digits and hyphens, at most 40 characters. Defaults to the name of the current directory.
-p, --profilestringAWS Profile
The AWS profile to use for the command. You can manage profiles using the aws-profile:* commands and set a default profile with defaults set.
For commands that use a connected AWS account, --profile (or AWS_PROFILE) selects the connected account the profile belongs to, unless --aws-account is set. The command fails if that account is not connected.
--quietbooleanQuiet
Hide progress, banners, success messages and hints. Command output, warnings and errors are still printed.
Related commands
dev— Run a whole stage locally against its deployed resources.dev --publicgives its web services and frontends public URLs the same way.bastion tunnel— Reach a database in your VPC from your machine, the opposite direction.