Flutter mobile

ClientException with SocketException: connection failed error OS error:Operation not permited,errno = 1) address = 10.0.2.2port = 8000 uri=http://10.0.2.2:8000/api/login

good day can you help me in this thank you in advance

this error appear when run the app in mobile devices but in emulator it runs well…

For us to have any possibility of helping you, you’re going to need to provide a lot more details - and probably post the code involved.

Is this error you’re getting in the client or on the server? If it’s in the client, are you seeing any corresponding request on the server?

from client…theres no corresponding request on the server…heres my code

Future login(String username, String password) async {
// String url = globals.url1;

String url = globals.getUrl();
globals.url = url;
// globals.showAlertDialog(context, ‘Error’, url);
try {

final response = await http.post(
Uri.parse('$url/api/login/'),
  body: {
    'username': username,
    'password': password,
  },
   );

if (response.statusCode == 200) {

    // If server returns a 200 OK response, parse the JSON
Map<String, dynamic> data = json.decode(response.body);
Map<String, dynamic> userInfo = data['userInfo'];

// Now you can access the user information
String firstName = userInfo['FirstName'];
String lastName = userInfo['LastName'];
String email = userInfo['email'];

globals.userfirstName = userInfo['FirstName'];
globals.userlastName = userInfo['LastName'];
globals.useremail = userInfo['email'];
Navigator.of(context).pushReplacement(
  MaterialPageRoute(
    builder: (context) => MyHomePage(firstName: firstName,
  lastName: lastName,
  email: email,),
  ),
);
// Redirect to the next screen or perform other actions here.

} else {
// Failed login, handle errors (e.g., show an error message to the user).

}

 } catch (error) {
 globals.showAlertDialog(context, 'Error', '$error');

}

}

If there’s no request being issued to the server, then I’m not sure that this is a Django issue. You’re likely going to get better help posting this issue in a “Flutter”-related forum.