A tester on another network needs to open a page served by your Linux machine. An ngrok HTTP tunnel connects a public endpoint to your local HTTP service.
This article covers checking the local server before forwarding its port, then using the HTTPS URL and request inspector to verify traffic.
TL;DR: Expose a Local HTTP Server with ngrok
Start your local web server first, then run ngrok against the port where that server listens to create a public endpoint.
- Authenticate the ngrok agent with ngrok config add-authtoken.
- Forward the correct port with ngrok http 8080, replacing 8080 with your app’s port.
- Use the HTTPS forwarding URL ngrok displays and stop the tunnel when sharing is over.
- Treat the public URL as public access unless you configure an access policy.
What Is an ngrok HTTP Tunnel?
An ngrok HTTP tunnel gives a remote tester a public endpoint for an HTTP service on your Linux machine. Router port forwarding is not part of this setup.
The public connection and the agent-to-upstream connection are separate legs. ngrok’s HTTPS endpoint handles TLS at its cloud service, while the upstream can use HTTP or HTTPS based on the address you give the agent. See the ngrok HTTP endpoint documentation for the current forwarding model.
The agent must be running and able to reach the upstream address.
Development services can use different listener ports. Check the startup message for the intended app’s port.
For a simple mapping, the relationship looks like this:
Remote browser → ngrok public endpoint → ngrok agent → local HTTP service:8080
A remote client can reach the app through the endpoint. Apply an access policy before distributing its URL.
How to Start an ngrok HTTP Tunnel on Linux
Keep the app and ngrok in separate terminal sessions. This lets you check application errors apart from tunnel status.
Step 1: Install the ngrok Agent
Download the Linux agent package or binary from ngrok’s official download page, choosing the build for your system architecture. Use that page’s current Linux installation instructions rather than an old archive name or package command.
If you use Kali Linux, our separate ngrok installation guide for Kali covers the distribution-specific setup. The agent is a command-line client. Check its help with this command if the installed package uses a different binary path: ngrok help.
Step 2: Add Your ngrok Authtoken
Sign in to your ngrok account and copy the agent authtoken from its dashboard. Add it to the agent’s configuration with the current CLI command:
ngrok config add-authtoken YOUR_AUTHTOKEN
For security, avoid publishing the token in code or request captures that include passwords, cookies, personal data or secret headers.
The official ngrok CLI reference documents the config subcommand.
The agent configuration stores the authtoken. For an application or automated environment, use that environment’s supported secret-management method rather than hard-coding the value in a script.
Step 3: Check the Local Web Server
Start the app or web server before launching ngrok, and check its local address with a browser or request tool. Our guide to hosting an HTTP server in one line shows a quick way to serve a test page.
Use 127.0.0.1 or localhost when the app and agent run on the same machine.
Check the app’s startup message for its port. For a container, ngrok on the host uses the host port published by that container.
When the app and agent run in separate containers, localhost points to the agent container. Put both on a shared network so the agent can address the app by its service name.
Before troubleshooting the endpoint, confirm the local service answers at its intended address. If it does not, resolve that local failure first.
Step 4: Forward the Listening Port
The example forwards the listener on port 8080:
ngrok http 8080
Keep the process open while you use the endpoint. Copy the forwarding address printed by your agent, since the URL and session details belong to that running session.
For a different local port, replace 8080 with that port. For a local TLS service, pass its full HTTPS address, for example ngrok http https://localhost:8443.
Step 5: Open the Public URL and Inspect Requests
Open the HTTPS forwarding URL printed by the agent from another browser or device. A page response confirms that the public endpoint can reach your app.
While a tunnel runs, the agent’s local inspection interface is available at http://localhost:4040. Use it to review HTTP requests and responses during development. For a webhook callback, check whether the provider reached the endpoint and what your app returned.
Do not share request captures that contain passwords, cookies, personal data or secret headers.
Troubleshoot ngrok HTTP Tunnel Problems
Connection failures often come from the service, destination or an application URL setting. Check the local service first, then inspect the session and response headers.
| Symptom | Likely check | Next action |
|---|---|---|
| Public URL reports a connection failure | Local app stopped or wrong port | Open the local service and match its listener port |
| Local service uses HTTPS | Agent is forwarding HTTP to an HTTPS upstream | Pass the full https://localhost:PORT address |
| Page redirects to localhost | Application generates absolute local URLs | Configure the app’s public base URL or trusted proxy handling |
| Browser shows an authentication prompt or policy response | Endpoint Traffic Policy is active | Review the policy and authorized identity |
| Inspector has no request | Request went to another endpoint or never arrived | Use the active forwarding URL and inspect the app port |
A local WordPress site may redirect visitors to its configured localhost address. Adjust its external base URL or trusted proxy handling to match the test environment.
For protocol-specific behavior, consult the ngrok endpoint documentation.
If the public page loads but the app returns an error, inspect its HTTP status and logs. Redirects, authentication responses and missing assets call for application or proxy changes.
Conclusion: Share the Endpoint, Not Your Machine
Keep the endpoint limited to the task. Test the local service first, then the agent’s URL, and stop the process when sharing ends.
The HTTP endpoint guide explains current endpoint settings, and the ngrok localhost guide covers the vendor’s share-and-test workflow.
FAQ
These answers cover the common setup choices for an HTTP tunnel.
What port should I use with ngrok http?
Use the port where your local HTTP service is listening. For example, use ngrok http 8080 when the service accepts requests on port 8080.
Does ngrok provide an HTTPS URL for an HTTP server?
ngrok can provide an HTTPS public endpoint and forward requests to a local HTTP upstream. TLS termination at ngrok’s edge does not mean the local upstream connection is also HTTPS.
How do I stop an ngrok tunnel?
Stop the running ngrok agent process in its terminal, usually with Ctrl+C. The endpoint remains available only while its agent session is active.
