skip to Main Content

This is Flutter app with python(flask)

error-image

If I debug, it shows an exception

debugging image

If I run the flutter app in chrome, it is interacting with flask and gives the correct response. But when I run this app in mobile, it shows the above error. I have included the internet permission in Android.manifest file.

2

Answers


  1. You can’t reach localhost (127.0.0.1) from your phone, it works on chrome because the browser is running on the same machine as the server.

    Use the local IP of your machine (e.g. 192.168.x.x) and make sure the phone/emulator is connected to the same network/wifi.

    Login or Signup to reply.
  2. If you are running your app on a real device and using localhost in Flask, that is most likely the problem. You cannot access your PC localhost directly on your mobile.

    If you are connected to your phone via a USB cable, then you can use the Google Chrome port forwarding option.

    Type chrome://inspect in the chrome search bar and select the port forwarding option.

    Then set the port and IP address. In your case, do as follows

    enter image description here

    Press done, now you can use localhost in your phone.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search