'OS Error: Connection refused, errno = 111, address = 127.0.0.1, when trying to run a hello world blockchain app

I'm trying to follow this GeekForGeeks tutorial on mac M1 via emulator but I'm seeing this error

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

when I run this line

_credentials = await _client.credentialsFromPrivateKey(_privateKey);

my ganache screenshot is this:

enter image description here

I have added

<uses-permission android:name="android.permission.INTERNET" />

but it's still not working.



Solution 1:[1]

If you are running this from an Android Emulator, you might want to take a look at: SocketException: OS Error: Connection refused, errno = 111 in flutter using django backend

10.0.2.2 would point to your localhost on your host machine where ganache is running.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1