- Published on
Flutter - Android app connection refused to local server when iOS & web work
- Authors
- Name
- Loi Tran
- @PrimeTimeTrann
Fix Android connection refused issue on Flutter / Android
Check if you can Google inside of the device browser. If you can then you've got an issue with your app and not the device. Proceed.
If you can't connect to any website on the browser, try changing your network DNS.
Make sure you've got the following inside of defined
Inside of this file:
./android/app/src/main/AndroidManifest.xml
Make sure you've got these tags & values.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
It should look like this.
<manifest>
<application
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
10.0.2.2
Try using an IP instead of localhost. Specifically Go from using localhost to a hardcoded IP address. Read more here.
const api = "http://10.0.2.2:7254";