gpt4 book ai didi

flutter - 尝试为 flutter_web 项目提供服务时无法创建本地服务器(地址已被使用)

转载 作者:IT王子 更新时间:2023-10-29 06:35:58 27 4
gpt4 key购买 nike

我尝试通过这个终端命令在本地启动 flutter web 项目

 webdev serve --auto restart

但是我收到以下错误信息

    Starting resource servers...Unhandled exception:
SocketException: Failed to create server socket (OS Error: Address already in use, errno = 48), address = 127.0.0.1, port = 8080
#0 _NativeSocket.bind (dart:io-patch/socket_patch.dart:591:7)
<asynchronous suspension>
#1 _RawServerSocket.bind (dart:io-patch/socket_patch.dart:1206:26)
#2 _ServerSocket.bind (dart:io-patch/socket_patch.dart:1466:29)
#3 ServerSocket.bind (dart:io-patch/socket_patch.dart:1457:26)
#4 _HttpServer.bind (dart:_http/http_impl.dart:2520:25)
#5 HttpServer.bind (dart:_http:227:19)
#6 HttpMultiServer.loopback.<anonymous closure> (package:http_multi_server/http_multi_server.dart:113:39)
#7 HttpMultiServer._loopback (package:http_multi_server/http_multi_server.dart:172:30)
<asynchronous suspension>
#8 HttpMultiServer.loopback (package:http_multi_server/http_multi_server.dart:111:12)
#9 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:83:33)
#10 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#11 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:54:36)
#12 ServerManager.start (package:webdev/src/serve/server_manager.dart:22:38)
#13 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#14 ServerManager.start (package:webdev/src/serve/server_manager.dart:18:37)
#15 _startServerManager (package:webdev/src/serve/dev_workflow.dart:85:27)
#16 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#17 _startServerManager (package:webdev/src/serve/dev_workflow.dart:66:42)
#18 DevWorkflow.start (package:webdev/src/serve/dev_workflow.dart:186:31)
#19 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#20 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#21 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#22 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#23 Future._complete (dart:async/future_impl.dart:473:7)
#24 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#25 _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async-patch/async_patch.dart:33:20)
#26 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#27 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#28 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:115:13)
#29 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:5)
abdullah@Abdullahs-MacBook-Pro ~/D/F/web_profile> webdev serve --auto restart
[SEVERE] Deleted previous snapshot due to missing asset graph.
[INFO] Building new asset graph completed, took 1.4s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Starting resource servers...Unhandled exception:
SocketException: Failed to create server socket (OS Error: Address already in use, errno = 48), address = 127.0.0.1, port = 8080
#0 _NativeSocket.bind (dart:io-patch/socket_patch.dart:591:7)
<asynchronous suspension>
#1 _RawServerSocket.bind (dart:io-patch/socket_patch.dart:1206:26)
#2 _ServerSocket.bind (dart:io-patch/socket_patch.dart:1466:29)
#3 ServerSocket.bind (dart:io-patch/socket_patch.dart:1457:26)
#4 _HttpServer.bind (dart:_http/http_impl.dart:2520:25)
#5 HttpServer.bind (dart:_http:227:19)
#6 HttpMultiServer.loopback.<anonymous closure> (package:http_multi_server/http_multi_server.dart:113:39)
#7 HttpMultiServer._loopback (package:http_multi_server/http_multi_server.dart:172:30)
<asynchronous suspension>
#8 HttpMultiServer.loopback (package:http_multi_server/http_multi_server.dart:111:12)
#9 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:83:33)
#10 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#11 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:54:36)
#12 ServerManager.start (package:webdev/src/serve/server_manager.dart:22:38)
#13 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#14 ServerManager.start (package:webdev/src/serve/server_manager.dart:18:37)
#15 _startServerManager (package:webdev/src/serve/dev_workflow.dart:85:27)
#16 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#17 _startServerManager (package:webdev/src/serve/dev_workflow.dart:66:42)
#18 DevWorkflow.start (package:webdev/src/serve/dev_workflow.dart:186:31)
#19 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#20 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#21 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#22 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#23 Future._complete (dart:async/future_impl.dart:473:7)
#24 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#25 _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async-patch/async_patch.dart:33:20)
#26 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#27 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#28 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:115:13)
#29 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:5)
abdullah@Abdullahs-MacBook-Pro ~/D/F/web_profile> webdev serve --auto restart
[SEVERE] Deleted previous snapshot due to missing asset graph.
[INFO] Starting resource servers...Unhandled exception:
SocketException: Failed to create server socket (OS Error: Address already in use, errno = 48), address = 127.0.0.1, port = 8080
#0 _NativeSocket.bind (dart:io-patch/socket_patch.dart:591:7)
<asynchronous suspension>
#1 _RawServerSocket.bind (dart:io-patch/socket_patch.dart:1206:26)
#2 _ServerSocket.bind (dart:io-patch/socket_patch.dart:1466:29)
#3 ServerSocket.bind (dart:io-patch/socket_patch.dart:1457:26)
#4 _HttpServer.bind (dart:_http/http_impl.dart:2520:25)
#5 HttpServer.bind (dart:_http:227:19)
#6 HttpMultiServer.loopback.<anonymous closure> (package:http_multi_server/http_multi_server.dart:113:39)
#7 HttpMultiServer._loopback (package:http_multi_server/http_multi_server.dart:172:30)
<asynchronous suspension>
#8 HttpMultiServer.loopback (package:http_multi_server/http_multi_server.dart:111:12)
#9 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:83:33)
#10 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#11 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:54:36)
#12 ServerManager.start (package:webdev/src/serve/server_manager.dart:22:38)
#13 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#14 ServerManager.start (package:webdev/src/serve/server_manager.dart:18:37)
#15 _startServerManager (package:webdev/src/serve/dev_workflow.dart:85:27)
#16 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#17 _startServerManager (package:webdev/src/serve/dev_workflow.dart:66:42)
#18 DevWorkflow.start (package:webdev/src/serve/dev_workflow.dart:186:31)
#19 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#20 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#21 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#22 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
abdullah@Abdullahs-MacBook-Pro ~/D/F/web_profile> webdev serve --auto restart
[SEVERE] Deleted previous snapshot due to missing asset graph.
[INFO] Building new asset graph completed, took 1.3s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Starting resource servers...Unhandled exception:
SocketException: Failed to create server socket (OS Error: Address already in use, errno = 48), address = 127.0.0.1, port = 8080
#0 _NativeSocket.bind (dart:io-patch/socket_patch.dart:591:7)
<asynchronous suspension>
#1 _RawServerSocket.bind (dart:io-patch/socket_patch.dart:1206:26)
#2 _ServerSocket.bind (dart:io-patch/socket_patch.dart:1466:29)
#3 ServerSocket.bind (dart:io-patch/socket_patch.dart:1457:26)
#4 _HttpServer.bind (dart:_http/http_impl.dart:2520:25)
#5 HttpServer.bind (dart:_http:227:19)
#6 HttpMultiServer.loopback.<anonymous closure> (package:http_multi_server/http_multi_server.dart:113:39)
#7 HttpMultiServer._loopback (package:http_multi_server/http_multi_server.dart:172:30)
<asynchronous suspension>
#8 HttpMultiServer.loopback (package:http_multi_server/http_multi_server.dart:111:12)
#9 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:83:33)
#10 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#11 WebDevServer.start (package:webdev/src/serve/webdev_server.dart:54:36)
#12 ServerManager.start (package:webdev/src/serve/server_manager.dart:22:38)
#13 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#14 ServerManager.start (package:webdev/src/serve/server_manager.dart:18:37)
#15 _startServerManager (package:webdev/src/serve/dev_workflow.dart:85:27)
#16 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#17 _startServerManager (package:webdev/src/serve/dev_workflow.dart:66:42)
#18 DevWorkflow.start (package:webdev/src/serve/dev_workflow.dart:186:31)
#19 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#20 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#21 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#22 Future._propagateToListeners (dart:async/future_impl.dart:668:32)

我试图通过从事件监视器中强制退出 dart 进程来解决这个问题,但我仍然得到同样的错误

是否可以将端口号从 8080 更改为任何端口号?

或者如果给定的默认端口不可用,无论如何自动更改端口号?

最佳答案

简答。

webdev serve web:8082

其中web是目录名,8082是端口号。

关于flutter - 尝试为 flutter_web 项目提供服务时无法创建本地服务器(地址已被使用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56816652/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com