I’m working on a Flutter mobile app that connects to a Django REST framework backend. My user registration endpoint works perfectly when I test it through Postman, but I’m getting connection issues when calling it from the Flutter app.
The weird thing is that a few registrations work fine at first, but then I start getting this socket error. I’m making requests to an HTTPS URL and already tried removing CSRF protection but that didn’t help.
My Flutter code:
var payload = {
'user_email': emailInputController.text,
'pass1': newPasswordController.text,
'pass2': confirmPasswordController.text,
};
// Making the HTTP call
http.post(registrationApiUrl,
headers: requestHeaders,
body: json.encode(payload))
.then((response) {
print(response.body);
}).catchError((error) {
print(error.toString());
});
Error message:
SocketException: OS Error: Connection refused, errno = 111
I should be getting back a JSON response with user details and an authentication token. Any ideas what might be causing this intermittent connection issue?