简体   繁体   中英

Expo- Could not connect to the server

i trying to open a new project in my iphone , and it shows this message: 在此处输入图片说明

NOTE: the connection is LAN , on TUNNEL mode it works fine but slow

You tried to connect to the wrong IP. the 127.0.0.1 is a localhost IP. You have to change to the IP where your Metro Builder Server runs on.

Maybe this Thread helps you to change to the correct IP: React Native Expo change default LAN IP

  • Change to LAN connection type in expo-cli
  • Open it again from your phone
  • If you get a similar error but with your LAN IP, your network does not allow connections between devices on the network, and you need to use tunnel or use simulator with localhost.
  1. Open Start > Control Panel > System
  2. Go to Advanced System Settings > Environment Variables
  3. Set a System Environment Variable with the following name/value pair:
  4. name: REACT_NATIVE_PACKAGER_HOSTNAME
  5. value: < the IPv4 address you want to use > (if any address does not work, enter the current address IPV4 you are using)

That's it!

IMPORTANT: remember to close and re-open the elevated PowerShell command prompt, since newly added Environment Variables wont' be available on the existing prompts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM