4

I was trying to link the flutter app with python with API. My python code generated http://127.0.0.1:5000/ URL. When I used this in flutter code it threw the error

Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = 127.0.0.1, port = 56782

I found a solution in this video

Why does this solution work??

1
  • You should try to add Internet permission in AndroidMenifest.xml file refer my answer here Commented Aug 7, 2021 at 18:27

1 Answer 1

7

If you use 127.0.0.1 in your emulator, it will refer to the android emulator not you pc.
And because there is no server running on android localhost at port 56782, it will create connection refused error.

In order to target you pc machine, where this emulator is running, you should be using 10.0.2.2. If you are using websocket and server is running on your pc, you can use ws://10.0.2.2 as socket url.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.