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

React-Native开发:同Wi-Fi下iPhone无法连接Node服务器求助

Hey there, let's work through your React Native server connectivity issue step by step!

问题拆解与解决方案

关于IPv6监听的判断

Your hunch is partially right. Looking at your sudo lsof -i output:

node 5420 user 46u IPv6 0x..... 0t0 TCP *:sunproxyadmin (LISTEN)

The *:sunproxyadmin doesn’t mean the server’s address is that string—* indicates the server is listening on all available IPv6 interfaces, and sunproxyadmin is just the IANA-assigned service name for port 8081. The actual problem is that your iPhone is likely using IPv4 on your local network, and IPv6 traffic might not be properly routed between your Mac and iPhone on the same Wi-Fi, hence the no-response issue.

How to let other devices access your server

Here are concrete steps to fix this:

1. Force the Metro server to listen on your Mac's IPv4 address

By default, Metro might prioritize IPv6. Start the server explicitly with your Mac's local IPv4 to bind it to that address:

npx react-native start --host 192.x.x.x03

Replace 192.x.x.x03 with the actual IPv4 address your Mac is using (the one you mentioned earlier). This makes the server directly accessible over IPv4, which your iPhone can connect to.

2. Check your Mac's firewall settings

Head to System Preferences > Security & Privacy > Firewall and make sure the node process is allowed to receive incoming connections. You can also temporarily disable the firewall for testing purposes (just remember to turn it back on afterward!).

3. Verify port accessibility

On your iPhone, open Safari and try accessing http://192.x.x.x03:8081/index.js directly. If it still fails, run this on your Mac's terminal to check if the port is open:

nc -zv 192.x.x.x03 8081

A successful response means the port is reachable; if not, double-check your server startup command and firewall settings.

About the server's startup IP address

You didn’t necessarily use a "wrong" IP—Metro defaults to listening on all interfaces (both IPv6 and IPv4) when no --host is specified. The issue is just that IPv6 isn’t playing nice with your iPhone's IPv4 connection on the local network.

Finding your correct local IP address

  • The 192.x.x.x03 you see on your Mac is your correct local IPv4 address—it’s assigned by your router, and it’s different from your router's IP (usually 192.x.x.x01, which is your iPhone's gateway). DNS is for domain name resolution and has nothing to do with the IP your server should bind to.
  • To confirm it, run this in your Mac's terminal:
    ifconfig | grep inet
    
    Look for the entry under your USB Wi-Fi interface (it might be named something like en1 or en2)—the value next to inet is your local IPv4.

Extra tips

  • Double-check that your iPhone and Mac are on exactly the same Wi-Fi network (no guest networks or isolated subnets, which often block device-to-device communication).
  • If all else fails, try restarting the Metro server, your Wi-Fi router, or resetting your iPhone's network settings (Settings > General > Transfer or Reset iPhone > Reset > Reset Network Settings).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 09:26:23