Skip to content

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 callingAddressNeeds
An app or browser on this computerhttp://localhost:8080Nothing extra
A phone, tablet or teammate on the same networkhttp://<this computer's LAN address>:8080Same Wi-Fi or wired network; firewall allows the port
An Android emulator on this computerhttp://10.0.2.2:8080Nothing extra
A service on the internet, such as a webhook senderhttps://….trycloudflare.com or an ngrok addressA tunnel program installed

Replace 8080 with your project's port.

Open the Share section ​

  1. Start the server.

  2. 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 ​

  1. Connect the phone to the same Wi-Fi network as the computer.

  2. On the computer, open Share and find Scan on your phone in the Local network (LAN) card.

  3. 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.

  4. 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 ufw turned on:

    bash
    sudo ufw allow 8080/tcp
  • Check 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://, not https://. 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:

ProgramAccountAddress you get
cloudflaredNone neededA new random https://….trycloudflare.com address each time
ngrokNeeds an ngrok account and its authtoken set onceAn ngrok https:// address

Start a tunnel ​

  1. Install cloudflared or ngrok and make sure it runs from a terminal. For ngrok, save your token once:

    bash
    ngrok config add-authtoken <token>
  2. Start the server and open Share.

  3. In Public internet (tunnel), choose cloudflared or ngrok.

  4. Select Start public tunnel.

    The status changes to Starting, then Live, and the public address appears in the card.

  5. Copy the address and give it to the caller, with an endpoint path added, for example https://calm-river-12.trycloudflare.com/webhooks.

  6. Select Stop tunnel when you are done.

StatusMeaning
OfflineNo tunnel is running. The mock is not reachable from the internet.
StartingWaiting for the tunnel program to report a public address.
LiveThe public URL works. Anyone who has it can reach your mock.
ErrorThe 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:

bash
cloudflared tunnel --url http://127.0.0.1:8080
bash
ngrok http 8080

The program prints the public address. Stop it with Ctrl + C.

Next steps ​