SocketException: Failed to create server socket(OS Error: Permission denied, errno = 13)

简介: SocketException: Failed to create server socket(OS Error: Permission denied, errno = 13)

问题:SocketException: Failed to create server socket (OS Error: Permission denied, errno = 13)。

在安卓手机上的表现就是白屏,无法显示页面。

I/flutter (25532): Observatory server failed to start after 1 tries
I/flutter (25532): Observatory server failed to start after 2 tries
I/flutter (25532): Observatory server failed to start after 3 tries
I/flutter (25532): Observatory server failed to start after 4 tries
I/flutter (25532): Observatory server failed to start after 5 tries
I/flutter (25532): Observatory server failed to start after 6 tries
I/flutter (25532): Observatory server failed to start after 7 tries
I/flutter (25532): Observatory server failed to start after 8 tries
I/flutter (25532): Observatory server failed to start after 9 tries
I/flutter (25532): Observatory server failed to start after 10 tries
I/flutter (25532): Observatory server failed to start after 11 tries
I/flutter (25532): Could not start Observatory HTTP server:
I/flutter (25532): SocketException: Failed to create server socket (OS Error: Permission denied, errno = 13), address = 127.0.0.1, port = 0
I/flutter (25532): #0      _NativeSocket.bind (dart:io-patch/socket_patch.dart:736:7)
I/flutter (25532): <asynchronous suspension>
I/flutter (25532): #1      _RawServerSocket.bind (dart:io-patch/socket_patch.dart:1394:26)
I/flutter (25532): #2      _ServerSocket.bind (dart:io-patch/socket_patch.dart:1676:29)
I/flutter (25532): #3      ServerSocket._bind (dart:io-patch/socket_patch.dart:1667:26)
I/flutter (25532): #4      ServerSocket.bind (dart:io/socket.dart:382:27)
I/flutter (25532): #5      _HttpServer.bind (dart:_http/http_impl.dart:2701:25)
I/flutter (25532): #6      HttpServer.bind (dart:_http:229:19)
I/flutter (25532): #7      Server.startup.poll (dart:vmservice_io/vmservice_server.dart:410:36)
I/flutter (25532): <asynchronous suspension>
I/flutter (25532): #8      Server.startup.poll (dart:vmservice_io/vmservice_server.dart)
I/flutter (25532): #9      Server.startup (dart:vmservice_io/vmservice_server.dart:422:23)
I/flutter (25532): <asynchronous suspension>
I/flutter (25532): #10     main (dart:vmservice_io:262:12)
I/flutter (25532): 

原因分析

从log中我们可以看出,错误信息是Permission denied,创建socket服务器失败。做Android开发的同学一看就应该知道了,这是因为没有网络权限。

为什么需要创建服务器呢,这是为了能够让HotReload正常运行。每当代码一修改,保存后会自动把代码push到手机。

解决方法

在Android目录中的AndroidManifest.xml文件中,添加网络权限即可。

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

参考:https://github.com/flutter/flutter/issues/32602

相关文章
|
11月前
|
Shell 数据库
【YashanDB知识库】YAS-00402 failed to connect socket, errno 111, error message "Connection refused"
【YashanDB知识库】YAS-00402 failed to connect socket, errno 111, error message "Connection refused"
【YashanDB知识库】YAS-00402 failed to connect socket, errno 111, error message "Connection refused"
|
11月前
|
Shell 数据库
【YashanDB知识库】YAS-00402 failed to connect socket, errno 111
【YashanDB知识库】YAS-00402 failed to connect socket, errno 111
|
应用服务中间件 nginx Windows
[emerg] 15060#200: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket ......
[emerg] 15060#200: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket ......
453 0
|
消息中间件 Kafka
org.apache.kafka.common.KafkaException: Socket server failed to bind to 114.115.20.100:9092: Cannot
org.apache.kafka.common.KafkaException: Socket server failed to bind to 114.115.20.100:9092: Cannot
221 0
|
前端开发 Python
解决报错:Websocket connection to‘ws://127.0.0.1:5000/socket.io/?EIO=4&transport=websocket’failed:Error
报错全文为:Websocket connection to‘ws://127.0.0.1:5000/socket.io/?EIO=4&transport=websocket’failed:Error during Websocket handshake:Unexpected response code:400。如下图所示。
解决报错:Websocket connection to‘ws://127.0.0.1:5000/socket.io/?EIO=4&transport=websocket’failed:Error
|
Java 关系型数据库 MySQL
14. 成功解决:ERROR:ssl_client_socket_impl.cc(992) handshake failed; returned -1, SSL error code 1, net_error -103
今天使用 Python 的 selenium 时,一直在报如下错误:[30616:22540:0328/093748.004:ERROR:ssl_client_socket_impl.cc(992)] handshake failed; returned -1, SSL error code 1, net_error -100
5618 0
|
JavaScript
Mac电脑npm:Failed to download repo vuejs-templates/webpack: tunneling socket could not be established,
Mac电脑npm:Failed to download repo vuejs-templates/webpack: tunneling socket could not be established,
224 0
|
网络协议 测试技术 网络安全
Python编程-Socket网络编程
Python编程-Socket网络编程
191 0
|
网络协议 开发者 Python
深度探索Python Socket编程:从理论到实践,进阶篇带你领略网络编程的魅力!
【7月更文挑战第25天】在网络编程中, Python Socket编程因灵活性强而广受青睐。本文采用问答形式深入探讨其进阶技巧。**问题一**: Socket编程基于TCP/IP,通过创建Socket对象实现通信,支持客户端和服务器间的数据交换。**问题二**: 提升并发处理能力的方法包括多线程(适用于I/O密集型任务)、多进程(绕过GIL限制)和异步IO(asyncio)。**问题三**: 提供了一个使用asyncio库实现的异步Socket服务器示例,展示如何接收及响应客户端消息。通过这些内容,希望能激发读者对网络编程的兴趣并引导进一步探索。
272 4