I/flutter (30720): SocketException: OS Error: Connection timed out, errno = 110, address = 192.19.170.13, port = 47763

Madhav Tripathi picture Madhav Tripathi · Feb 10, 2020 · Viewed 8.5k times · Source

I'm using a real device (not an android emulator) backend: MongoDb Atlas, API: strapi-beta, getting this error: I/flutter (30720): SocketException: OS Error: Connection timed out, errno = 110, address = 192.19.170.13, port = 47763 (found a lot of similar questions but none of them were using a real device for testing)

    try {
      var ip = '192.19.170.13';
      setState(() => _isSubmitting = true);
      http.Response response =
          await http.post('http://$ip:1337/auth/local/register',
 /* I've also tried using localhost(it didn't work) everyone suggested to use my loopback adapter's (Ethernet's ip address) even that isn't working.*/
 body: {
        'username': _username,
        'email': _email,
        'password': _password,
      });

      final responseData = json.decode(response.body);
      setState(() => _isSubmitting = false);
      _successSnackBar();
      print(responseData);
    } catch (e) {
      setState(() => _isSubmitting = false);
      print(e.toString());
    }
  }

Answer

Nehal Jaisalmeria picture Nehal Jaisalmeria · Jan 31, 2021

If you're working on Chrome, you need to go to

chrome://inspect/#devices

and add your port to 'Port Forwarding' like this

enter image description here

And make sure you have USB Debugging on your device.