Expo 'Network request failed' in Production Build: Fix
API calls work in Expo Go but fail with 'Network request failed' in your release build? Find the real error in the device log, then check the API URL, EAS environment variables, plain HTTP and certificates.
"Network request failed" in an Expo release build almost always means the request never left the phone or was blocked by the operating system. The usual causes are an API URL that is undefined or points to localhost, a plain http:// address that Android and iOS block in release builds, and a TLS certificate problem. Read the native device log first, because it names the exact reason, then work through the causes below.
In development, Expo Go and the dev client run with a forgiving network setup and your local .env file. A release build uses your EAS settings, the platform security rules and the real production server. A request that worked on your laptop network can fail for reasons that have nothing to do with your code. The JavaScript error is also useless on its own: React Native's fetch throws the same TypeError: Network request failed for a dozen different problems.
Step 1: Get the Real Error From the Device Log
Do not guess from the JavaScript message. Install the release build on a real device and read the native log.
# Android: show recent errors from your app
adb logcat -d | grep -iE "cleartext|ssl|certificate|unable to resolve|timeout"
Typical Android lines:
Cleartext HTTP traffic to api.example.com not permittedmeans you are callinghttp://.UnknownHostExceptionorUnable to resolve hostmeans the host name is wrong or empty.SSLHandshakeExceptionorTrust anchor for certification path not foundmeans a certificate problem.
On iOS, open Xcode, go to Window, Devices and Simulators, select your device and open its console. An http:// call shows "App Transport Security policy requires the use of a secure connection". A TLS failure shows an NSURLErrorDomain code such as -1200 or -1202.
Also log the exact URL before every call. Half of these bugs are solved by seeing undefined/api/login in the log.
Step 2: Check the API URL Your Build Actually Uses
If the URL is built from an environment variable, the release build may not have it. Expo inlines EXPO_PUBLIC_ variables into the JavaScript bundle at build time. Your .env file is usually in .gitignore, so an EAS cloud build never sees it and the value becomes undefined. A URL of undefined/api/login then fails as a network error.
Create the variable in EAS and link the environment to your build profile. The EAS environment variables docs cover this in detail.
eas env:create --name EXPO_PUBLIC_API_URL --value https://api.example.com --environment production --visibility plaintext
{
"build": {
"production": {
"environment": "production"
}
}
}
Two more details. The variable name must start with EXPO_PUBLIC_, or it is not exposed to your app code. And you must read it as process.env.EXPO_PUBLIC_API_URL, with dot notation. Bracket access and destructuring are not inlined. Changing a variable also needs a new build, because the value is baked into the bundle. If this sounds familiar from web apps, the same trap exists in Next.js, covered in environment variables undefined in production.
Next, check that the URL is not a development address. These work only on your machine or network:
http://localhost:3000points at the phone itself, not your laptop.http://192.168.x.x:3000works only on your Wi-Fi.http://10.0.2.2:3000is the Android emulator's alias for your computer and does nothing on a real device.
Step 3: Stop Using Plain HTTP
Android 9 and later block cleartext HTTP by default in release builds, and iOS App Transport Security blocks it too. Expo Go and development tooling hide this, so the first failure shows up in your TestFlight or Play build. A GitHub issue in the Expo repository and this Expo forum thread show the same pattern: works in development, fails in the built app.
The real fix is HTTPS. Put your API behind a proper certificate, which most hosts and CDNs provide for free.
If you need a short-term bridge, for example a staging server on plain HTTP, install expo-build-properties and enable cleartext traffic for Android:
{
"expo": {
"plugins": [
["expo-build-properties", { "android": { "usesCleartextTraffic": true } }]
]
}
}
Spell it exactly usesCleartextTraffic. People report that a misspelled key such as useCleartextTraffic is silently ignored and the build still fails. This setting needs a new native build, not an OTA update. Do not ship it to production. It lets any network observer read and change your traffic, and store reviewers may ask why.
Step 4: Check the Certificate
If the log shows an SSL or trust error, test the server from outside:
openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts
Look for three things: the certificate is not expired, the host name matches, and the server sends the full chain, including the intermediate certificate. A browser or an iOS device can sometimes repair a missing intermediate on its own, while Android does not, so the same API works on one platform and fails on the other. Fix it on the server by installing the full chain file your certificate authority gives you. Self-signed certificates on a staging server fail in release builds on both platforms.
Step 5: Rule Out the Server
Once the URL and TLS are fine, call the same endpoint from your computer:
curl -i https://api.example.com/health
If curl works but the phone does not, compare headers. Some firewalls and bot protection rules block requests with unusual user agents or from certain countries, and mobile carriers sometimes sit behind different IP ranges than your office. If curl also fails or returns 5xx, the problem is the backend, not the app. Remember that CORS does not apply to native apps, so a CORS error is not the explanation here.
A backend change can also break only some app versions. If you renamed a route or changed a response field, old installed versions keep calling the old shape. Version your API or keep the old route alive until old app versions fade out.
Step 6: Make the Next Failure Obvious
Wrap fetch once, so every failure tells you what happened:
const API_URL = process.env.EXPO_PUBLIC_API_URL;
if (!API_URL) {
throw new Error("EXPO_PUBLIC_API_URL is not set in this build");
}
export async function api(path: string, init?: RequestInit) {
const url = `${API_URL}${path}`;
try {
const res = await fetch(url, init);
if (!res.ok) {
throw new Error(`HTTP ${res.status} from ${url}`);
}
return res;
} catch (err) {
console.warn("api call failed", url, err);
throw err;
}
}
The startup check turns a silent undefined into a loud error you will see in your first release test. Test every release build on a real device on mobile data, not only on your office Wi-Fi, before you submit it. For the launch-time version of this problem, see Expo app crashes on launch in production.
How Relia Helps
Relia records sessions, screens, taps, API calls and crashes in your React Native or Expo app, tagged with the app version and release. A failing call in the app is joined to the backend request behind it. That tells you quickly whether requests are failing before they leave the phone, as with an undefined URL, or failing on your server. If a backend change breaks only one version of the app, the incident shows both sides and which users were affected. Setup: run npx relia-sdk@latest init in your app folder, and follow the React Native setup guide.
FAQ
Why does my Expo app work in Expo Go but fail in the production build?
Expo Go uses your local .env and allows insecure traffic that release builds block. A release build only has the variables you gave EAS, and it follows Android and iOS network security rules. Check the device log for the exact error.
Why does Network request failed happen only on Android?
The usual reasons are plain http:// URLs, which Android 9 and later block, and server certificates with a missing intermediate that Android will not repair. Check adb logcat for "Cleartext" or "SSLHandshakeException".
Do I need usesCleartextTraffic in app.json?
Only for plain HTTP servers, and only as a temporary measure. Use HTTPS for any production API.
Why is my EXPO_PUBLIC variable undefined in the EAS build?
Your .env file is not uploaded when it is gitignored, and the build does not know the variable. Create it with eas env:create, link the environment in eas.json and build again.
Does an OTA update fix a network error caused by a native setting?
No. Cleartext and security settings are part of the native build, so you need a new binary. A JavaScript-only change, such as fixing the URL, can ship over the air.