Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using localhost with Flutter & testing with iOS device

I'm trying to figure out how to have an iOS device reach my node server from flutter. Node is listening on port 5000, and as you can see in my request is trying port 5000. Currently, I'm getting back a network error 'Connection refused, errno = 61'. Any idea how to fix it?

var url = 'http://localhost:5000/photo';

try {
  final res = await http.post(
    url,
    body: {'photo': photo, 'dir': destination},
    headers: {"Accept": "*/*", "Connection": "keep-alive"},
  );
  print(res.body);
  if (res.statusCode >= 400) {
    final resBody = json.decode(res.body);
    throw HttpException(resBody['errors'][0]);
  }
} catch (err) {
  throw (err);
}
like image 588
Patrick Avatar asked Oct 20 '25 04:10

Patrick


1 Answers

you should use your computer ip

  • for windows you can run ipconfig

  • for linux you can run ifconfig

  • for mac you can run Ipconfig

like image 191
nordine enn Avatar answered Oct 21 '25 16:10

nordine enn