Comprehensive troubleshooting guide for fixing Expo connection refused, 401 errors, loopback binding, and firewall issues on Windows.
This skill outlines a systematic approach to resolving common connectivity and authentication blockers when developing React Native (Expo) apps on Windows, interacting with a local backend.
Symptom:
401 Unauthorized regardless of login state.Root Cause:
Resolution:
// frontend/services/api.ts
api.interceptors.response.use(
(response) => response,
async (error) => {
if (error.response?.status === 401) {
// Trigger global logout (clear SecureStore, reset state)
logoutCallback?.();
}
return Promise.reject(error);
}
);
Symptom:
Uncaught Error: Java.net.ConnectException: Connection refusedhttp://IP:4000) or Expo Bundler (http://IP:8081).Root Cause:
Resolution:
New-NetFirewallRule -DisplayName "PulseFit Backend" -Direction Inbound -LocalPort 4000 -Protocol TCP -Action Allow -Profile Private,Public
New-NetFirewallRule -DisplayName "Expo Bundler" -Direction Inbound -LocalPort 8081 -Protocol TCP -Action Allow -Profile Private,Public
Symptom:
exp://127.0.0.1:8081.Root Cause:
localhost adapter instead of the LAN Wi-Fi adapter.Resolution:
REACT_NATIVE_PACKAGER_HOSTNAME to your computer's LAN IP before starting.$env:REACT_NATIVE_PACKAGER_HOSTNAME="10.236.122.122"; npx expo start --lan --clear
Symptom:
ipconfig shows a different IPv4 address than what is hardcoded in api.ts.Resolution:
frontend/services/api.ts BASE_URL matches the current machine IP.const api = axios.create({
baseURL: 'http://10.236.122.122:4000/api',
timeout: 10000, // 10s timeout
});