SocketException: Connection failed (OS Error: Operation not permitted, errno = 1) with flutter app on macOS


I have following code in my Flutter app where MyDataLoader is a widget which starts up from main.dart


import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

class MyDataLoader extends StatefulWidget {
  _MyDataLoaderState createState() => _MyDataLoaderState();

class _MyDataLoaderState extends State<MyDataLoader> {
  void getData() async {
    final response = await http.get('');

  void initState() {

  Widget build(BuildContext context) {
    return Scaffold(
      body: Text('MyDataLoader screen'),

Above code is inspired from I get the following error when MyDataLoader widget loads up:

[ERROR:flutter/lib/ui/] Unhandled Exception:
SocketException: Connection failed (OS Error: Operation not permitted,
errno = 1), address =, port = 443

Above error is of course because of the following line of code called when my widget is loading.

final response = await

But, if I open on my browser, I am able to to see that it has dummy json which I expect to receive in the response. This means I am well connected to internet.

I am running my app on macOS Big Sur version 11.1.

What am I doing wrong? Do I need to declare some permissions for my app to be able to access internet from a macOS environment?


macOS needs you to request a specific entitlement in order to access the network. To do that open macos/Runner/DebugProfile.entitlements and add the following key-value pair.


Then do the same thing in macos/Runner/Release.entitlements.

You can read more about this in the Desktop support for Flutter documentation.

Answered By – Suragch

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *