Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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());
    }
  }
like image 597
Madhav Tripathi Avatar asked Feb 10 '20 17:02

Madhav Tripathi


3 Answers

check your device network connection(emulator or real device) and machine network connection(computer) are same.

  • mobile data turn off
  • user wifi data which are used on your machine.

problem solved.

like image 134
AK IJ Avatar answered Sep 18 '22 14:09

AK IJ


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.

like image 39
Nehal Jaisalmeria Avatar answered Sep 16 '22 14:09

Nehal Jaisalmeria


Well, if you are doing the tests with a local server and you are on windows. The error is probably due to the windows firewall. You could disable the firewall and it should work or add a rule to the firewall to allow tcp access to the mentioned port.

like image 45
RickGremory Avatar answered Sep 17 '22 14:09

RickGremory