Intro
When an Expo app fails to reach an API, load a bundle, or connect to a development server, the root cause is often a networking misconfiguration rather than a bug in your JavaScript. This guide walks through a structured troubleshooting workflow for Expo networking: starting with environment inventory, moving through safe configuration changes, verification, diagnostics, failure modes, and an operations checklist. You will learn how to inspect DNS resolution, test ports and connectivity, adjust config files without breaking other parts of your app, and recover from common failure modes.
The examples assume you are using Expo SDK 48 or later with React Native 0.71 or newer, but the concepts apply to any recent Expo version. Commands are shown for macOS and Linux; Windows users can use PowerShell equivalents where noted. Throughout, we use placeholders like <project-directory> or <your-lan-ip> to avoid leaking real environment details.
This article is for developers who need to diagnose connectivity problems in local development, on physical devices, or in CI/CD pipelines. By the end, you will have a reproducible process: observe first, change one thing at a time, verify, and document recovery before an incident forces a hasty fix.
Version and Environment Inventory
Before touching any configuration, establish a baseline. You need to know the Expo SDK version, the React Native version, the exact command you use to start the project, and how the app connects to your backend or Metro bundler. Run these read-only commands from your project root:
# From your project directory
npx expo --version
# Expected output example: 6.3.10
node -e "console.log(require('./node_modules/react-native/package.json').version)"
# Expected output example: 0.72.10
npx expo config --type public
# Expected output: JSON containing name, slug, version, ios.bundleIdentifier, android.package, etc.
Also check the current app.json or app.config.js for any extra fields that might affect networking (e.g., custom API URLs). A read-only observation is just looking; do not edit yet.
Prerequisites: You have Node.js 16 or 18 installed, the Expo CLI available via npx, and the project dependencies installed (npm install or yarn). If you are testing on a physical device, both the development machine and the device must be on the same local network (unless you use a tunnel).
Failure signal: if npx expo --version returns an error like "command not found" or a very old version (e.g., 2.x), stop and update the Expo CLI. Most networking fixes assume recent CLI versions.
Blast radius: running these commands changes nothing. They are safe.
Recovery: not needed for this step because no state is modified.
Safe Configuration Path
Expo networking configuration lives in several places: app.json (or app.config.js), metro.config.js, environment variables (e.g., EXPO_PACKAGER_PROXY_URL), and sometimes native project files if you have ejected. The safest path is to change one file at a time, keep a backup, and restart the bundler with cache cleared to verify.
Common configuration changes
In app.json, under expo.extra, add your dev server host and port. For a local backend running on port 3000:
- Set a custom API URL for development
{
"expo": {
"extra": {
"apiUrl": "http://192.168.1.20:3000"
}
}
}
Then access it in code with Constants.expoConfig.extra.apiUrl (from expo-constants).
Verification: after editing, run npx expo config --type public and check that extra.apiUrl appears in the output.
Recovery: if the change breaks something, revert the extra block and restart the bundler.
Sometimes you need a specific port because another process uses 8081. Create or edit metro.config.js in the project root:
- Override Metro bundler host/port
const { getDefaultConfig } = require('expo/metro-config');
const config = getDefaultConfig(__dirname);
config.server.port = 8082;
module.exports = config;
Then start the bundler with npx expo start --port 8082.
Expected: terminal shows "Metro waiting on exp://192.168.1.20:8082".
Recovery: remove the server.port line and restart normally.
Never hardcode production URLs or tokens in app.json. Use .env files with EXPO_PUBLIC_ prefix (available in SDK 49+):
- Use environment variables for sensitive values
# .env
EXPO_PUBLIC_API_URL=https://staging-api.example.com
Access with process.env.EXPO_PUBLIC_API_URL in your code.
Verification: restart the bundler and log the value in a development-only console statement.
Recovery: if the variable is undefined, check that the .env file is in the project root and the bundler was restarted.
Safe change principles
- One scoped item at a time. If you change both
app.jsonandmetro.config.jssimultaneously, you cannot tell which change caused a new failure. - Keep backups. Use
cp app.json app.json.bakbefore editing, or rely on git. - Blast radius: changing
app.jsonaffects the whole project; changingmetro.config.jsaffects only the bundler. Choose the smallest file that achieves your goal. - Verification after every change: run the project and test the specific network call that was failing.
Verification and Diagnostics
After making a configuration change, you must verify that the network path works end-to-end. Use these diagnostics in order.
1. Check that the dev server is reachable
Start Expo:
npx expo start
Note the URL shown, e.g., exp://192.168.1.20:8081. From your development machine, open a browser to http://192.168.1.20:8081/status (Metro's status endpoint). You should see packager-status:running.
If this fails, Metro is not listening. Check for port conflicts with lsof -i :8081 (macOS/Linux) or netstat -ano | findstr :8081 (Windows).
2. Verify DNS resolution
If your app uses a hostname like api.mybackend.com, confirm DNS works from both the dev machine and the device.
On dev machine:
nslookup api.mybackend.com
# Expected: an IP address in the ANSWER SECTION
On a physical device, you cannot run nslookup easily. Instead, use a simple fetch inside your Expo app in development mode:
// Add temporarily to App.js in a useEffect
fetch('https://api.mybackend.com/health')
.then(response => console.log('Status:', response.status))
.catch(error => console.log('DNS/Network error:', error.message));
If the error is Network request failed or TypeError: Network request failed, the hostname may not resolve on the device's network. Try using the IP address directly to isolate DNS vs. routing.
3. Test TCP connectivity to a specific port
Use telnet or nc from the dev machine to see if a port is open on the target server:
# Test if port 3000 is open on 192.168.1.100
nc -vz 192.168.1.100 3000
# Expected on success: Connection to 192.168.1.100 port 3000 [tcp/*] succeeded!
If the connection is refused, the server may not be listening on that interface or a firewall is blocking it.
4. Inspect Expo's own network logs
Run the bundler with verbose logging:
DEBUG=expo:* npx expo start
Look for lines like [expo] Starting project at ..., [expo] Opening on Android..., or errors such as Unable to reach Expo servers. These logs often reveal proxy or certificate issues.
5. Use expo-cli doctor
Run npx expo-doctor to check for common project misconfigurations that can affect networking (e.g., incompatible dependency versions):
npx expo-doctor
Expected output lists any issues found; fix them before further network debugging.
Failure Modes and Recovery
Here are the most common failure modes in Expo networking, their causes, and step-by-step recovery paths.
Failure mode 1: "Network request failed" on Android emulator
Cause: The Android emulator uses 10.0.2.2 to refer to the host machine's localhost. If your API URL is http://localhost:3000, the emulator tries to reach its own localhost, not your dev machine.
How to avoid: Always use 10.0.2.2 instead of localhost when running on the Android emulator. In your app, use Platform.OS === 'android' ? 'http://10.0.2.2:3000' : 'http://localhost:3000'.
Recovery if already broken: Change the base URL in your code or environment variable, clear the Metro cache (npx expo start --clear), and reload the app.
Failure mode 2: Physical device cannot connect to Metro
Cause: The device and dev machine are on different Wi-Fi networks, or the dev machine's firewall blocks port 8081.
How to avoid: Ensure both are on the same network. On macOS, allow Node in System Settings > Network > Firewall. On Windows, allow Node.js through Windows Defender Firewall.
Recovery: Switch to tunnel mode: npx expo start --tunnel. This uses a public ngrok URL, bypassing local network restrictions. Note: tunnel mode may be slower and requires internet on both ends.
Failure mode 3: App loads but API calls fail with CORS errors (web only)
Cause: When testing in a web browser, cross-origin requests to your API are blocked unless the API sends appropriate CORS headers.
How to avoid: Configure your backend to include Access-Control-Allow-Origin: * for development, or set up a proxy in Expo web.
Recovery: If you cannot change the backend, add a proxy to app.json for web:
{
"expo": {
"web": {
"build": {
"babel": {
"include": ["expo-router"]
}
},
"dev": {
"proxy": {
"/api": {
"target": "http://localhost:3000",
"changeOrigin": true
}
}
}
}
}
}
Then call /api/... from your web app instead of the full URL. Restart the bundler.
Failure mode 4: "Unable to resolve module" when using a custom Metro config
Cause: A misconfigured metro.config.js can break module resolution.
How to avoid: Always start from getDefaultConfig(__dirname) and only add minimal customizations, testing after each addition.
Recovery: Restore the original metro.config.js (or delete it) and run npx expo start --clear.
Failure mode 5: Slow or timeouts when using fetch in development
Cause: Sometimes the JS debugger (Chrome DevTools) causes network slowness due to long-running debugger connections.
How to avoid: Disable the debugger or use React Native DevTools (Hermes) instead. Also, avoid logging large responses.
Recovery: Close the debugger, reload the app, and retest.
Operations Checklist
Use this checklist before and after making networking changes in an Expo project. It is intended for a single accountable owner (for example, the developer leading the debugging session) and should be revisited at the start of each debugging session and after each change.
- [ ] Owner: Priya Shah, Engineering Lead. Revisit frequency: at each debugging session start.
- [ ] Run
npx expo --versionand record the output in a scratchpad. If version is older than 6.0.0, update Expo CLI first. - [ ] Run
npx expo config --type publicand verify theextrafields match what the app expects. - [ ] Start the bundler with
npx expo startand confirm the status endpoint returnspackager-status:running. - [ ] On the dev machine, test DNS resolution with
nslookup <api-hostname>and capture the resolved IP. - [ ] Test the target API port using
nc -vz <host> <port>and note whether it succeeds. - [ ] If using a physical device, confirm both device and dev machine are on the same Wi-Fi network. If not, switch to tunnel mode.
- [ ] If changing configuration, back up the file first (
cp file file.bak) and make only one change at a time. - [ ] After each change, restart the bundler with cache cleared (
npx expo start --clear) and reload the app. - [ ] Verify the specific network call now succeeds: log
response.statusor use a network inspector. - [ ] If the issue persists, revert the last change using the backup and test again to confirm the baseline.
- [ ] Document the final working configuration in a
NETWORKING.mdfile in the repo, including the exact URLs, ports, and any special environment variables used.
Common Pitfalls and How to Avoid Them
- Hardcoding localhost in app code. Always use a configurable base URL and environment-specific overrides. This prevents accidental production calls to localhost.
- Ignoring platform differences. Android emulator needs
10.0.2.2, iOS simulator can uselocalhost, and physical devices need the LAN IP or tunnel. Write a small helper to pick the right base URL. - Clearing caches too rarely. Metro caches aggressively. When a config change seems to have no effect, run
npx expo start --clear. - Testing over cellular data. Your dev server or API may be firewalled from the cellular network. Stick to Wi-Fi in development, or use a public tunnel.
- Putting secrets in app.json. Env vars with
EXPO_PUBLIC_are safer. Also add.envto.gitignore. - Making multiple changes at once. If you change the API URL and the port simultaneously, you won't know which fixed or broke things. Change one variable at a time.
- Not checking Expo's own logs. The
DEBUG=expo:*output often contains the exact error (e.g., proxy authentication failure).
Conclusion
Expo networking troubleshooting becomes predictable when you follow a structured process: inventory the environment, make one scoped configuration change at a time, verify with concrete commands, and know the recovery path for each failure mode. The examples in this guide give you the exact commands to run and the expected outputs to look for, from npx expo config --type public to nc -vz and npx expo start --clear.
As a next step, pick one low-risk verification from the Operations Checklist and run it against your current project. Record the current state, execute the check, compare the result with the expected signal, and then review any dependencies such as React Native version, Android emulator settings, or CI/CD environment variables. A reliable workflow makes failure visible, protects sensitive values, limits changes to the intended resource, and defines recovery verification before an incident forces a hasty decision.