'SocketException (SocketException: No route to host (OS Error: No route to host, errno = 113)

I have a Flask application running on my local machine, which I'm using as a backend for the Flutter application , but I'm getting this error

SocketException (SocketException: No route to host (OS Error: No route to host, Errno = 113)
Future pix(String BackgroundImagePath, String originalImagePath) async {
      final uri = Uri.parse('http://my desktop address:5000').replace(queryParameters: {
        'original': originalImagePath,
        'background': BackgroundImagePath,
      });
    
      final response = await http.get(uri);
  • The phone is connected to my laptop through a USB
  • Both phone & Laptop are on same WIFI
  • I replaced localhost with my Ubuntu desktop IP address


Solution 1:[1]

Try adding this line in your AndroidManifest.xml, inside the <manifest> tag. I had the same problem and this solved it.

<uses-permission android:name="android.permission.INTERNET"/>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dani3le_