Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SocketException:Connection failed (OS Error: Network is unreachable, errno = 101), address = 10.0.2.2, port = 80

Tags:

flutter

dart

Making a login screen in flutter when i tap the login it gives the error 'network is Unreachable'.

I have change the ip addresses "10.0.2.2" , "8.7.7.7" but doesn't work.

Error :

E/flutter (16082): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled 
Exception: SocketException: Connection failed 
(OS Error: Network is unreachable, errno = 101), address = 10.0.2.2, port = 80

CODE :

TextEditingController user=new TextEditingController();
TextEditingController pass=new TextEditingController();

Future<List> _login() async{
  final response = await http.post("http://127.0.0.1/my_store/login.php", body: {
    "username": user.text,
    "password": pass.text,
   
  });

  print(response.body);
  }

like image 795
Taha Ali Avatar asked Jan 26 '23 03:01

Taha Ali


1 Answers

In my case turning on the wifi and making sure that it is connected solved the issue.enter image description here

like image 90
Zahra Avatar answered May 10 '23 05:05

Zahra