Share on LAN or the internet
A running mock can be called from the same computer, from other devices on your network, or from anywhere through a public tunnel. The Share section lists the address for each case.
Which address to use
| Who is calling | Address | Needs |
|---|---|---|
| An app or browser on this computer | http://localhost:8080 | Nothing extra |
| A phone, tablet or teammate on the same network | http://<this computer's LAN address>:8080 | Same Wi-Fi or wired network; firewall allows the port |
| An Android emulator on this computer | http://10.0.2.2:8080 | Nothing extra |
| A service on the internet, such as a webhook sender | https://….trycloudflare.com or an ngrok address | A tunnel program installed |
Replace 8080 with your project's port.
Open the Share section
Start the server.
Select Share in the rail.
The page has three cards: This computer, Local network (LAN) and Public internet (tunnel). Click any address to copy it. While the server is stopped, a banner reads Your server is stopped. Start it first — then these URLs will be reachable. and the addresses cannot be copied.
This computer
The This computer card shows http://localhost: and the port. Use it from a browser, curl or an app running on the same machine.
localhost always means "the device making the request". Typed into a phone's browser, it points at the phone, not at your computer. A phone needs a LAN address.
Local network (LAN)
The Local network (LAN) card lists an address for each network your computer is connected to, such as http://192.168.1.20:8080. Any device on the same network can use it.
Open the mock on a phone
Connect the phone to the same Wi-Fi network as the computer.
On the computer, open Share and find Scan on your phone in the Local network (LAN) card.
Point the phone's camera at the QR code and open the link.
The code holds the first LAN address in the list. The phone's browser opens the mock's base address.
Add an endpoint path to the address, for example
/health.
The base address alone, with no path, usually returns the mock's 404 reply, because few projects have an endpoint for /. That reply still proves the phone reached the mock.
In a mobile app you are developing, set the API base URL to the LAN address instead of localhost.
Android emulator
An Android emulator runs in its own small network. Use http://10.0.2.2: and the port to reach the computer the emulator runs on. The card shows this address as a reminder.
If a device cannot connect
Check both devices are on the same network. Guest Wi-Fi networks and some office or café networks stop devices from seeing each other.
Check the firewall on the computer. It must allow incoming connections on the mock's port. On Ubuntu with
ufwturned on:bashsudo ufw allow 8080/tcpCheck the address. If the card reads
No LAN address detected. Are you connected to a network?, connect to a network and open the Share section again.Use
http://, nothttps://. The mock serves plain HTTP on the LAN.
More cases are in Troubleshooting.
Good to know
While a project's server is running, it listens on all of the computer's network connections, not only on localhost. Devices on the same network can reach it at the LAN address whether or not you open the Share section. Stop the server when you are done.
Public internet (tunnel)
A tunnel gives the mock a temporary public https:// address. Requests to that address are carried to the mock on your computer. Use it when something outside your network has to call the mock: a webhook from a payment or code-hosting service, a teammate at home, or a phone on mobile data.
Mock Studio does not include a tunnel program. It starts one that is installed on your computer:
| Program | Account | Address you get |
|---|---|---|
| cloudflared | None needed | A new random https://….trycloudflare.com address each time |
| ngrok | Needs an ngrok account and its authtoken set once | An ngrok https:// address |
Start a tunnel
Install
cloudflaredorngrokand make sure it runs from a terminal. For ngrok, save your token once:bashngrok config add-authtoken <token>Start the server and open Share.
In Public internet (tunnel), choose cloudflared or ngrok.
Select Start public tunnel.
The status changes to Starting, then Live, and the public address appears in the card.
Copy the address and give it to the caller, with an endpoint path added, for example
https://calm-river-12.trycloudflare.com/webhooks.Select Stop tunnel when you are done.
| Status | Meaning |
|---|---|
| Offline | No tunnel is running. The mock is not reachable from the internet. |
| Starting | Waiting for the tunnel program to report a public address. |
| Live | The public URL works. Anyone who has it can reach your mock. |
| Error | The tunnel stopped or never started. The message below says why. |
Things to know:
- One tunnel runs at a time. Stop it to switch program or project.
- Stopping or restarting the server also stops a tunnel that points at it.
- If the card reads cloudflared is not installed or ngrok is not installed, install the program, then open the Share section again.
- If ngrok does not report an address within about ten seconds, the card shows
ngrok did not report a public URL. Is your authtoken set?
DANGER
A public tunnel puts your mock on the open internet. Anyone who has the address can call every enabled endpoint in the project, with no login, for as long as the tunnel runs. Before you start one:
- keep real secrets, tokens and personal data out of response bodies and headers;
- turn off Proxy passthrough, or be sure you want strangers' requests forwarded to the real API behind it;
- remember that the Require an auth header switch accepts any value, so it does not protect anything;
- stop the tunnel as soon as you have finished.
Tunnels with the snap
The snap package runs in a sandbox and cannot start cloudflared or ngrok, so Start public tunnel does not work there. LAN sharing is not affected. Either install the .deb package, or run the tunnel program yourself in a terminal while the server is running:
cloudflared tunnel --url http://127.0.0.1:8080ngrok http 8080The program prints the public address. Stop it with Ctrl + C.
Next steps
- Live request log: watch requests from other devices arrive.
- Auth, CORS and project settings: change the port or turn CORS off.
- Troubleshooting