39

I am trying to develop Flutter app which will run also on destkop. This app is using http package:

import 'package:http/http.dart'

When I am trying to perform http request I am getting this exception:

 SocketException: Connection failed (OS Error: Operation not permitted, errno = 1), address = firebasedynamiclinks.googleapis.com, port = 443

This app is working on Android and iOS, how to enable this permission for macos?

I am using IntelliJ IDE, so this answer is not satisfying me Flutter - http.get fails on macos build target: Connection failed

K.Os
  • 5,123
  • 8
  • 40
  • 95
  • Does this answer your question? [Flutter - http.get fails on macos build target: Connection failed](https://stackoverflow.com/questions/57841871/flutter-http-get-fails-on-macos-build-target-connection-failed) – smorgan Apr 14 '20 at 05:13

2 Answers2

119

You need to add:

<key>com.apple.security.network.client</key>
<true/>

to macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements.

This is documented here.

Gazihan Alankus
  • 11,256
  • 7
  • 46
  • 57
smorgan
  • 20,228
  • 3
  • 47
  • 55
  • 2
    Very important: do not add any whitespace to the node, sth. your IDE might do on save when formatting this file. This will result in obscure code signing issues later on. – TomTom101 Jan 21 '22 at 15:54
  • 3
    note: a Hot Reload doesn't apply these settings, you'll need to stop & restart the app to take effect – RumbleFish Jan 18 '23 at 23:25
0

you should give "Outgoing Connections (Client)" permission to your project through Xcode. for a complete explanation check this link.

Payam Zahedi
  • 827
  • 7
  • 20
  • 3
    You should not do this with Xcode. See https://stackoverflow.com/questions/57841871/flutter-http-get-fails-on-macos-build-target-connection-failed/57841872#57841872 and my comment in the question you linked to. – smorgan Apr 14 '20 at 05:14
  • Also is better to give the actual concrete absolute response here, with a side note to the link. Most likely that link will not exists when someone is reading the response. – Pedro Luz Sep 09 '22 at 04:27