简体   繁体   中英

Could Not Connect my react app via ip4 address

This is my first time making react project.

After I run my project with npm run start, I can connect to it via localhost:3000 and 127.0.0.1:3000 without any problem.

But when I try to connect it with my LAN address on the same computer it shows

Could Not Connect Description: Could not connect to the requested server host.

It also shown an error on browser console.

Failed to load resource: the server responded with a status of 502 (internal error - server connection terminated)

This same project can be open via ip4 if I run it on my laptop. I can even open it from my mobile in the same wifi.

My computer is own by company so I think something might block it.

Please give me your suggestions on how to fix this problem. What could possibly cause this problem.

Any insight would be helpful.

Thank you.

Run HOST=0.0.0.0 npm run start

Check your IP. <your-ip>:3000 would work.

https://create-react-app.dev/docs/advanced-configuration/ for setting HOST environment variables.

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