When using Expo Go on a physical device, the app can't access localhost. You need to use your computer's IP address.
Mac/Linux:
ifconfig | grep "inet " | grep -v 127.0.0.1Look for something like 192.168.1.100 or 10.0.0.5
Windows:
ipconfigLook for "IPv4 Address" under your active network adapter (usually 192.168.x.x)
Or check Network Settings:
- Mac: System Preferences → Network
- Windows: Settings → Network & Internet → Properties
Edit app.json and update the apiUrl in the extra section:
{
"expo": {
"extra": {
"apiUrl": "http://YOUR_IP_ADDRESS:3000"
}
}
}Example:
{
"expo": {
"extra": {
"apiUrl": "http://192.168.1.100:3000"
}
}
}After updating app.json, restart Expo:
# Stop Expo (Ctrl+C)
# Then restart
npm startIn a separate terminal:
npm run apiThe API server should show:
🚀 PDF API Server running on http://localhost:3000
- Open the app in Expo Go
- Try to search for a PDF
- Check the status logs - you should see "✅ API connected"
- Make sure
npm run apiis running - Check that your IP address is correct
- Make sure your phone and computer are on the same WiFi network
- Check firewall settings - port 3000 might be blocked
- Try temporarily disabling firewall to test
- Make sure API server is actually running
- Verify IP address is correct
- Make sure phone and computer are on same network
- Try pinging your computer's IP from another device
You can also set the API URL via environment variable:
# Mac/Linux
export API_URL=http://192.168.1.100:3000
npm start
# Windows
set API_URL=http://192.168.1.100:3000
npm startThen update app.json:
{
"expo": {
"extra": {
"apiUrl": process.env.API_URL || "http://localhost:3000"
}
}
}When deploying, update apiUrl in app.json to your production API server URL.