Tutorials
Your first tunnel
Give an app already running on localhost a public HTTPS address.
Give an app already running on your computer a public HTTPS address. Femtoport's agent makes an outbound connection, so you do not need to open an inbound port on your router.
Before you start
Have your app running locally and a terminal on the same computer. This guide uses http://127.0.0.1:8000; substitute your app's actual address and port throughout. Open that address in your browser first to confirm it works. If you do not have an app yet, use the optional sample page at the end.
You also need a Femtoport account that can create tunnels. The dashboard will guide you through any account setup and credit requirements.
Open the dashboard and sign in. Public access needs workspace traffic credit and active service access; use Buy credit or, if offered, Free trial available → Activate free trial. You can set up the tunnel first and add credit before opening its public URL.
1. Create the tunnel
- In the dashboard, choose Create new tunnel. If the credit prompt appears, follow it to add credit or select Set up tunnel anyway and return to credit before testing the URL.
- Under What do you want to share?, choose Web app or API. In Target URL, enter
http://127.0.0.1:8000and choose Create tunnel. This address is interpreted from the agent's machine, so run the agent on the same computer as your app. - The Agent token screen displays the assigned hostname and commands. Under Linux/macOS or Windows, copy Install the femtoport CLI for your machine. The command already contains this tunnel's secret token. Keep it private: anyone with the token can run an agent for the tunnel. Avoid sharing the command, screenshots, terminal history, or clipboard contents with others.
The page is public once the agent connects. To require a password before connecting, choose Done, open the tunnel row, and under Basic auth turn on Require basic auth. Enter a username and a strong password, then choose Add user. Keep those credentials separate from the agent token. Protect your app before connecting it or sharing its URL; its own authentication and security still matter.
2. Install and run the agent
Open a terminal on the same computer and paste the command copied from the dashboard. The following show the command shapes; use your dashboard's actual command and token rather than the placeholder.
Linux or macOS:
curl -fsSL https://cdn.femtoport.com/install-cli.sh | sh -s -- --token='YOUR_AGENT_TOKEN'
Windows PowerShell:
$ProgressPreference = 'SilentlyContinue'
$p=Join-Path $env:TEMP 'femtoport-install-cli.ps1'
Invoke-WebRequest -UseBasicParsing https://cdn.femtoport.com/install-cli.ps1 -OutFile $p
& $p -Token 'YOUR_AGENT_TOKEN'
The installer downloads and runs software from Femtoport, installs a per-user femtoport command, and saves the token beside the binary, replacing any token previously saved by this per-user CLI installer. On Linux or macOS it uses curl, sh, and sha256sum or shasum; on Windows, use PowerShell. Protect that account and token file. After installation, open a new terminal if the installer says the command is not on the current shell's PATH. Start the agent:
femtoport
Leave this terminal running. The CLI installer installs the command; it does not start a background service. To stop this foreground agent later, press Ctrl+C in its terminal. The dashboard also offers Install as a service and Run in this folder, plus All platforms and options for downloads and checksums.
3. Open the public URL
Return to the dashboard. The tunnel row should change from Waiting for agent to Online. Open the tunnel row and follow its hostname link, or use Copy public URL and paste it into a browser. If you enabled Basic auth, enter the username and password you created. You should see your app at your assigned HTTPS address. Online means an agent is connected; opening the URL verifies the local page is answering too.
If it does not work
- Waiting for agent: make sure
femtoportis still running on the intended machine, the copied command used this tunnel's token, and the machine can reach the internet over HTTPS. Check the terminal for errors. - Online, but the page does not load: check
http://127.0.0.1:8000on the agent machine. Keep your app running and check the tunnel's Target URL and port. A target of127.0.0.1means the agent's own machine. - URL unavailable: check the tunnel is enabled, the workspace has traffic credit and active service access, and the dashboard reports no separate service hold. A workspace owner can add credit or access time.
- Password prompt fails: use the tunnel's Basic auth credentials, not the agent token or email sign-in code. Open the tunnel's settings to check its access users.
When finished, stop the foreground agent with Ctrl+C. To pause the public endpoint from the dashboard, open the tunnel row and turn off Tunnel enabled. You can re-enable it and run your app and agent again to repeat the test.
Optional: start a sample page
Only this optional example needs Python 3. On Linux or macOS, use python3; on Windows, use the Python launcher py.
Use a new folder containing only a harmless test page. Everything served by this web server can become reachable through the public URL. Run the commands for your computer and leave this terminal open.
Linux or macOS:
cd "$(mktemp -d "${TMPDIR:-/tmp}/femtoport-first-page.XXXXXX")"
printf '<h1>Hello from my first tunnel</h1>\n' > index.html
python3 -m http.server 8000 --bind 127.0.0.1
Windows PowerShell:
$pageDir = Join-Path $env:TEMP ("femtoport-first-page-" + [guid]::NewGuid())
New-Item -ItemType Directory -Path $pageDir | Out-Null
Set-Location $pageDir
Set-Content index.html '<h1>Hello from my first tunnel</h1>'
py -m http.server 8000 --bind 127.0.0.1
If py is unavailable but Python 3 is installed, use python in its place. Open http://127.0.0.1:8000 on that machine: you should see Hello from my first tunnel. If port 8000 is in use, stop the other server or choose another port in both the command and the target below. Do not put an agent token or other private files in this served folder.
Return to Create the tunnel above and use http://127.0.0.1:8000 as the target. Stop the sample server with Ctrl+C when finished.