gistmax. Back to DiscoverStudio
Technology

Fix Network request failed when an Expo app calls localhost

By Gistmax Tutorials · 2026-11-04

App development: Fix Network request failed when an Expo app calls localhost. Workflow: identify, diagnose, fix, verify.
App development: Fix Network request failed when an Expo app calls localhost. Workflow: identify, diagnose, fix, verify.

An API works in the computer’s browser but cannot be reached from a physical phone. The app is configured with http://localhost:8000 and reports a network failure.

Why this happens

On the phone, localhost refers to the phone itself, not the development computer. Device routing, firewall rules and platform transport requirements can also prevent the connection.

Step-by-step solution

1. Identify where the app is running: physical device, emulator or simulator. Use the backend address appropriate to that environment.

2. For a physical device on a trusted local network, expose the development server on the intended interface and use the computer’s reachable LAN address. Check the firewall narrowly.

3. For deployed builds, use the intended HTTPS API URL. Inspect server logs and certificate errors instead of treating every failure as CORS.

Worked example

A phone and laptop on the same network might use a laptop LAN address such as http://192.168.1.20:8000 during development. That illustrative address must be replaced with the actual reachable address.

Verify the fix

Open a harmless health endpoint from the phone and then request it from the app. Verify the production build uses the deployed API rather than the development address.

Prevent a repeat

Keep environment-specific public API origins explicit. Never disable transport protections broadly just to make one development URL work.

Reference

Official documentation or standards guidance

An original Gistmax troubleshooting guide. Scenarios and sample values are illustrative; configuration depends on your software version and environment. Cover diagram: Gistmax Tutorials.

Join the conversation →