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());
}
}
check your device network connection(emulator or real device) and machine network connection(computer) are same.
problem solved.
If you're working on Chrome, you need to go to
chrome://inspect/#devices
and add your port to 'Port Forwarding' like this
And make sure you have USB Debugging on your device.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With