Description
Copied from flutter issue #132912
Steps to reproduce
Just make a network request.
For example, using the basic http package.
Also relevant when using other packages, such as Dio.
The same error, and in the same versions of Flutter.
Therefore, I think they have the same root.
The bug is very critical, as already many communities of various applications complain about it.
I have given the simplest code example below.
The main essence is in the line:
await http.get(Uri.parse('https://flutter.dev'));
This request throws an exception:
SocketException (SocketException: Failed host lookup: 'flutter.dev' (OS Error: ... , errno = 11004))
This error appears on ANY host of the many that I have tried.
That is, the problem is not in a particular host.
This problem is relevant for Windows (which discards many other similar problems that can be found on the Internet and which are associated with missing permissions on the Android system). It's not that problem.
I've reproduced this bug in the latest master as well as in the latest stable release.
On the Internet people advise to downgrade Flutter to version 3.10.5, where this problem does not reproduce. I personally haven't tried it yet, but I suspect that all versions after 3.10.5 have this bug.
But downgrading to that version is not an option for me anyway.
Please fix this bug as soon as possible.
Yes, this exception is skippable, but it creates debugging inconvenience in many cases.
Moreover, this problem is relevant for many.
Thank you!
Expected results
No exception
Actual results
This request throws an exception:
SocketException (SocketException: Failed host lookup: 'flutter.dev' (OS Error: ... , errno = 11004))
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Future<void> _test() async {
try {
await http.get(Uri.parse('https://flutter.dev'));
} catch (ex) {
// ignore: use_build_context_synchronously
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Result'),
content: Text(
ex.toString(),
),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: _test,
child: const Icon(Icons.error),
),
);
}
}
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
Is there an existing issue for this?
I have searched the [existing issues](https://github.com/flutter/flutter/issues)
I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)
Steps to reproduce
Just make a network request.
For example, using the basic http package.
Also relevant when using other packages, such as Dio.
The same error, and in the same versions of Flutter.
Therefore, I think they have the same root.
The bug is very critical, as already many communities of various applications complain about it.
I have given the simplest code example below.
The main essence is in the line:
await http.get(Uri.parse('https://flutter.dev'));
This request throws an exception:
SocketException (SocketException: Failed host lookup: 'flutter.dev' (OS Error: ... , errno = 11004))
This error appears on ANY host of the many that I have tried.
That is, the problem is not in a particular host.
This problem is relevant for Windows (which discards many other similar problems that can be found on the Internet and which are associated with missing permissions on the Android system). It's not that problem.
I've reproduced this bug in the latest master as well as in the latest stable release.
On the Internet people advise to downgrade Flutter to version 3.10.5, where this problem does not reproduce. I personally haven't tried it yet, but I suspect that all versions after 3.10.5 have this bug.
But downgrading to that version is not an option for me anyway.
Please fix this bug as soon as possible.
Yes, this exception is skippable, but it creates debugging inconvenience in many cases.
Moreover, this problem is relevant for many.
Thank you!
Expected results
No exception
Actual results
This request throws an exception:
SocketException (SocketException: Failed host lookup: 'flutter.dev' (OS Error: ... , errno = 11004))
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Future<void> _test() async {
try {
await http.get(Uri.parse('https://flutter.dev'));
} catch (ex) {
// ignore: use_build_context_synchronously
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Result'),
content: Text(
ex.toString(),
),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: _test,
child: const Icon(Icons.error),
),
);
}
}
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.14.0-8.0.pre.17, on Microsoft Windows [Version 10.0.22621.2134], locale ru-UA)
• Flutter version 3.14.0-8.0.pre.17 on channel master at C:\SDK\Flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 6f227c0784 (2 days ago), 2023-08-18 19:04:15 -0700
• Engine revision f4bffdcf85
• Dart version 3.2.0 (build 3.2.0-87.0.dev)
• DevTools version 2.26.1
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at C:\SDK\Android
• Platform android-33-ext5, build-tools 33.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = C:\Program Files\Chromium\chrome
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.1)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.7.34009.444
• Windows 10 SDK version 10.0.22621.0
[✓] Android Studio (version 2022.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
[✓] VS Code (version 1.81.1)
• VS Code at C:\Users\Yegor\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.70.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.2134]
• Chrome (web) • chrome • web-javascript • unknown
• Edge (web) • edge • web-javascript • Microsoft Edge 115.0.1901.203
[✓] Network resources
• All expected network resources are available.