title: SocketException: Failed host lookup: 'www.xyz.com' (OS Error: nodename nor servname provided, or not known errno = 8)
body: <p>I wrote a Flutter app which connects to a web server running on a separate machine using the dart http package. On my local machine (Mac) I added the hostname 'www.xyz.com' to /etc/hosts and everything works fine when using the IOS Simulator. I would like to test the app on a real device (iPhone SE) but don't want to jailbreak the device. Because it's not possible to edit the hosts file on the phone without jailbreaking it, I installed Weblock which allows to setup redirect rules. I am able to start the app on my phone, however, when making a request to the web server on the separate machine (in my local network) I get the following error:</p>
  
  <p><code>SocketException: Failed host lookup: 'www.xyz.com' (OS Error: nodename nor servname provided, or not known errno = 8)</code></p>
  
  <p>From outside the app I can access the web server via 'www.xyz.com' in my browser. </p>
  
  <p>To summarize:</p>
  
  <ul>
  <li>App running in IOS simulator on machine A and connecting to web server on machine B -> works fine</li>
  <li>App running on real device and connecting to web server on machine B -> error</li>
  <li>Connecting to web server on machine B via browser on Phone -> works fine</li>
  </ul>
  
  <p>Output <code>flutter doctor -v</code></p>
  
  <pre><code>[✓] Flutter (Channel stable, v1.12.13, on Mac OS X 10.15.4 19E287, locale en-DE)
      • Flutter version 1.12.13 at /Users/Jonas/Documents/Programming/flutter
      • Framework revision cf37c2cd07 (5 months ago), 2019-11-25 12:04:30 -0800
      • Engine revision b6b54fd606
      • Dart version 2.7.0
  
  
  [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
      • Android SDK at /Users/Jonas/Library/Android/sdk
      • Android NDK location not configured (optional; useful for native profiling support)
      • Platform android-R, build-tools 29.0.3
      • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
      • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
      • All Android licenses accepted.
  
  [✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
      • Xcode at /Applications/Xcode.app/Contents/Developer
      • Xcode 11.4.1, Build version 11E503a
      • CocoaPods version 1.9.1
  
  [✓] Android Studio (version 3.6)
      • Android Studio at /Applications/Android Studio.app/Contents
      • Flutter plugin version 44.0.2
      • Dart plugin version 192.7761
      • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
  
  [✓] IntelliJ IDEA Ultimate Edition (version 2019.3.4)
      • IntelliJ at /Applications/IntelliJ IDEA.app
      • Flutter plugin version 45.0.2
      • Dart plugin version 193.6911.31
  
  [!] IntelliJ IDEA Community Edition (version 2019.1.2)
      • IntelliJ at /Applications/IntelliJ IDEA CE.app
      ✗ Flutter plugin not installed; this adds Flutter specific functionality.
      ✗ Dart plugin not installed; this adds Dart specific functionality.
      • For information about installing plugins, see
        https://flutter.dev/intellij-setup/#installing-the-plugins
  
  [✓] Connected device (1 available)
      • Jonass iPhone • 5ea0e7db176aeb6f278f88f410fb9d0fd4256658 • ios • iOS 13.4.1
  
  ! Doctor found issues in 1 category.
  </code></pre>
  
  <p>Thanks!</p>