SocketException: Failed host lookup Flutter / Dart Origin: On your device Last updated 4 Nov 2026

Flutter: Unhandled Exception: SocketException: Failed host lookup: 'api.example.com' (OS Error: No address associated with hostname, errno = 7)

The app could not resolve or reach the server: no internet, wrong host name, DNS failure, or missing network permission.

Exact message you may see SocketException: Failed host lookupUnhandled Exception: SocketException: Failed host lookupSocketException: Connection refused (OS Error: Connection refused, errno = 111)SocketException: Connection failed (OS Error: Network is unreachable, errno = 101)SocketException: OS Error: No address associated with hostname
Seen on: Flutter Android

Meaning

On Android release builds INTERNET permission must be declared in AndroidManifest.xml (debug builds include it automatically, which hides the bug). On emulators check connectivity; for localhost use 10.0.2.2 on the Android emulator. Always catch exceptions around HTTP calls.

Common causes

  • No network or offline emulator
  • Missing <uses-permission android:name="android.permission.INTERNET"/> in release
  • Using localhost from the Android emulator (use 10.0.2.2)
  • Typo in the host
  • DNS/VPN/proxy problems

⚡ Quick fix

  1. Add the INTERNET permission to the main AndroidManifest
  2. Use 10.0.2.2 or your LAN IP for local servers
  3. Wrap calls in try/catch and show an offline message

Detailed fix by platform

Android

  1. <uses-permission android:name="android.permission.INTERNET" /> in android/app/src/main/AndroidManifest.xml

How to diagnose

  1. Release — Only in release builds?
  2. Host — Correct and resolvable?
  3. Emulator — localhost vs 10.0.2.2?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Android license status unknown / licenses not accepted — flutter doctor: Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses (Flutter / Dart)Android license statu…App Transport Security has blocked a cleartext HTTP load — iOS: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection (NSURLErrorDomain -1022) (Flutter / Dart)App Transport Securit…BoxConstraints forces an infinite width — Flutter: BoxConstraints forces an infinite width. These invalid constraints were provided to RenderStack's layout() function (TextField in a Row) (Flutter / Dart)BoxConstraints forces…Cleartext HTTP traffic not permitted — Flutter (Android): java.io.IOException: Cleartext HTTP traffic to api.example.com not permitted (Flutter / Dart)Cleartext HTTP traffi…Dependency requires compileSdk 34 or later — Android Gradle: Execution failed for task ':app:checkDebugAarMetadata'. Dependency requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs (Flutter / Dart)Dependency requires c…FormatException: Unexpected character — Dart: FormatException: Unexpected character (at character 1) <!DOCTYPE html> — jsonDecode of an HTML page (Flutter / Dart)FormatException: Unex…HandshakeException: CERTIFICATE_VERIFY_FAILED — Dart: HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate) (Flutter / Dart)HandshakeException: C…NetworkImageLoadException: HTTP request failed, statusCode: 404 — Flutter: Exception caught by image resource service — NetworkImageLoadException: HTTP request failed, statusCode: 404, https://example.com/a.png (Flutter / Dart)NetworkImageLoadExcep…SocketExc…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.