'Flutter app does not start in debug mode

I had simple Flutter app with debug config. After I change the gradle config and other stuff to build apk in release mode.I did all the config based on the documentation and release build works fine. But now I cannot run app in debug mode. It show this error

I/flutter (15809): Observatory server failed to start after 11 tries
I/flutter (15809): Could not start Observatory HTTP server:
I/flutter (15809): SocketException: Failed to create server socket (OS Error: Permission denied, errno = 13), address = 127.0.0.1, port = 0
I/flutter (15809): #0      _NativeSocket.bind (dart:io/runtime/binsocket_patch.dart:545:7)
I/flutter (15809): <asynchronous suspension>
I/flutter (15809): #1      _RawServerSocket.bind (dart:io/runtime/binsocket_patch.dart:1138:10)
I/flutter (15809): #2      _ServerSocket.bind (dart:io/runtime/binsocket_patch.dart:1385:10)
I/flutter (15809): #3      ServerSocket.bind (dart:io/runtime/binsocket_patch.dart:1375:26)
I/flutter (15809): #4      _HttpServer.bind (dart:_http/http_impl.dart:2503:10)
I/flutter (15809): #5      HttpServer.bind (dart:_http:276:19)
I/flutter (15809): #6      Server.startup.poll (dart:vmservice_io/server.dart:352:36)
I/flutter (15809): <asynchronous suspension>
I/flutter (15809): #7      Server.startup (dart:vmservice_io/server.dart:364:23)
I/flutter (15809): <asynchronous suspension>
I/flutter (15809): #8      main (dart:vmservice_io:239:12)
I/flutter (15809):

It shows white screen and nothing get loaded.



Solution 1:[1]

When building the release version it says to remove internet permission if the app does not need it. But when we are doing the development we must keep that.Because internet permission is required to work hot reload. After I added

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

to the manifest, everything works fine

Solution 2:[2]

I solved the same problem after a long time. It is not just the INTERNET permission in AndroidManifest.xml. In my case, I received the same error, but I noticed that my project did not have the debug folder inside app> src.

I needed to create this folder manually and insert the file AndroidManifest.xml. With the code below:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your_app_package_name">
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

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
Solution 2 Rodrigo Souza