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

Expo项目LAN模式无法连接,tunnel模式异常求助

Expo项目LAN模式连接失败问题

问题现象

  • 执行npx expo start --lan启动项目时,无法通过二维码或exp://链接访问,报错内容:Uncaught Error: java.io.IOException: Failed to download remote update
  • 使用--tunnel模式启动存在限制或异常
  • --localhost模式可正常启动,网页版与模拟器运行无问题

已排查操作

  • 确认设备处于同一局域网,未使用VPN
  • 多次重建项目、检查并更新依赖包
  • 排查过代理、DNS、防火墙设置
  • 测试空白Expo项目仍存在相同问题
  • 已在~/.bashrc中配置ANDROID_HOME与JAVA_HOME环境变量
  • 操作系统:EndeavourOS

项目依赖包

- ─ @babel/core@7.26.0
- ├── @expo/html-elements@0.11.0
- ├── @expo/vector-icons@14.0.4
- ├── @gluestack-ui/accordion@1.0.8
- ├── @gluestack-ui/actionsheet@0.2.46
- ├── @gluestack-ui/alert-dialog@0.1.32
- ├── @gluestack-ui/alert@0.1.16
- ├── @gluestack-ui/avatar@0.1.18
- ├── @gluestack-ui/button@1.0.8
- ├── @gluestack-ui/checkbox@0.1.33
- ├── @gluestack-ui/divider@0.1.10
- ├── @gluestack-ui/fab@0.1.22
- ├── @gluestack-ui/form-control@0.1.19
- ├── @gluestack-ui/icon@0.1.25
- ├── @gluestack-ui/image@0.1.11
- ├── @gluestack-ui/input@0.1.32
- ├── @gluestack-ui/link@0.1.23
- ├── @gluestack-ui/menu@0.2.37
- ├── @gluestack-ui/modal@0.1.35
- ├── @gluestack-ui/nativewind-utils@1.0.26
- ├── @gluestack-ui/overlay@0.1.16
- ├── @gluestack-ui/popover@0.1.43
- ├── @gluestack-ui/pressable@0.1.17
- ├── @gluestack-ui/progress@0.1.18
- ├── @gluestack-ui/radio@0.1.34
- ├── @gluestack-ui/select@0.1.30
- ├── @gluestack-ui/slider@0.1.26
- ├── @gluestack-ui/spinner@0.1.15
- ├── @gluestack-ui/switch@0.1.23
- ├── @gluestack-ui/textarea@0.1.24
- ├── @gluestack-ui/toast@1.0.8
- ├── @gluestack-ui/tooltip@0.1.37
- ├── @legendapp/motion@2.4.0
- ├── @react-navigation/bottom-tabs@7.2.0
- ├── @react-navigation/native-stack@7.2.0
- ├── @react-navigation/native@7.0.14
- ├── @types/jest@29.5.14
- ├── @types/react-native@0.73.0
- ├── @types/react-test-renderer@19.0.0
- ├── @types/react@18.3.18
- babel-plugin-module-resolver@5.0.2
- expo-blur@14.0.1
- expo-constants@17.0.3
- expo-font@13.0.2
- expo-haptics@14.0.0
- expo-linking@7.0.3
- expo-router@4.0.15
- expo-splash-screen@0.29.18
- expo-status-bar@2.0.0
- expo-symbols@0.2.0
- expo-system-ui@4.0.6
- expo-web-browser@14.0.1
- expo@52.0.23
- glob@11.0.0
- jest-expo@52.0.2
- jest@29.7.0
- jscodeshift@17.1.1
- nativewind@4.1.23
- react-dom@18.3.1
- react-native-css-interop@0.1.22
- react-native-gesture-handler@2.20.2
- react-native-reanimated@3.16.6
- react-native-safe-area-context@4.12.0
- react-native-screens@4.4.0
- react-native-svg@15.8.0
- react-native-web@0.19.13
- react-native-webview@13.12.5
- react-native@0.76.5
- react-test-renderer@19.0.0
- react@18.3.1
- rimraf@6.0.1
- tailwindcss@3.4.17
- typescript@5.7.2

解决方法

  1. 手动指定LAN模式绑定的IP
    部分系统存在多网卡或IP识别异常,直接指定本地局域网IP启动:

    npx expo start --lan --host 你的本地局域网IP
    

    可通过ip a命令查看本地IP。

  2. 匹配Expo Go与项目版本
    确保手机上的Expo Go应用版本与项目expo包版本(当前为52.0.23)一致,版本不兼容会导致更新下载失败。

  3. 清理Expo缓存后重启

    npx expo start --lan --clear
    
  4. 开放Expo默认端口组
    Expo默认使用19000-19006端口,确认防火墙开放这些端口的UDP和TCP协议访问权限。

  5. 添加Expo配置指定hostType
    在项目根目录的app.json或app.config.js中添加配置:

    {
      "expo": {
        "hostType": "lan",
        "ios": {
          "bundleIdentifier": "你的iOS包名"
        },
        "android": {
          "package": "你的Android包名"
        }
      }
    }
    
  6. 尝试降级Expo到稳定版本
    当前使用的expo@52.0.23为较新版本,可能存在兼容性问题,尝试降级到51.x稳定版:

    npm install expo@51.0.28
    

    同步更新expo-router、jest-expo等相关依赖到对应版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 03:40:13