You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure SWA CLI升级后localhost无法解析问题求助

解决Azure Static Web Apps CLI 1.1.4版本localhost解析错误的线索
  • 替换localhost为127.0.0.1执行命令
    直接使用回环IP替代localhost,执行以下命令:
    swa start http://127.0.0.1:3000 --api-devserver-url http://127.0.0.1:7071
    部分环境下localhost的域名解析可能存在异常,用IP可绕过解析环节。

  • 检查本地hosts文件配置
    确认系统hosts文件中存在127.0.0.1 localhost和::1 localhost的映射:

    • Windows路径:C:\Windows\System32\drivers\etc\hosts
    • macOS/Linux路径:/etc/hosts
      若缺失则手动添加,保存后刷新DNS缓存:
      • Windows:执行ipconfig /flushdns
      • macOS:执行sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • 降级CLI版本验证兼容性
    临时降级到之前可用的版本(如1.1.3),排查是否为新版本问题:
    npm install -g @azure/static-web-apps-cli@1.1.3
    重新执行启动命令,确认功能是否恢复。

  • 添加--host参数强制绑定IP
    执行命令时指定绑定回环IP:
    swa start http://localhost:3000 --api-devserver-url http://localhost:7071 --host 127.0.0.1
    强制CLI使用指定IP,避免自动解析异常。

  • 验证本地DNS解析有效性
    在终端执行ping localhost和ping 127.0.0.1,确认两者均能正常返回回环IP响应。若ping localhost无响应,优先修复hosts配置。

内容的提问来源于stack exchange,提问作者jkim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 17:02:07