1

I'm trying to access my application on my phone by running it on my local network. When starting the React app there are two urls. One is localhost and the other one on my network.

enter image description here

I can access the application with the On Your Network URL when using the device that I'm running the app on, however, the problem is that I can't access it from any other device.

I tried to change the port, aswell as running: npm start --port 3000 --host 0.0.0.0 (with 0.0.0.0 being my ip address).

I get an error saying:

This site can't be reached. 0.0.0.0 (with 0.0.0.0 again being my ip address) took to long to respond.

Marcus
  • 29
  • 1
  • 5

3 Answers3

0

In my case the problem was solved by disabling McAfee firewall and opening windows start. Searching control panel and opening it. Then in the upper left corner search for firewall and click on Allow an app through Windows Firewall. Then click change settings and enable Node.js JavaScript Runtime on both private and public.

Marcus
  • 29
  • 1
  • 5
0

In case of Ubuntu users, turn off your firewall,

sudo ufw disable
Sravan Kumar
  • 602
  • 8
  • 22
-1

You can use HOST for this.

run HOST=0.0.0.0 npm run start, then open the "On Your Local Network" link on another device.

Caio Amorim
  • 165
  • 6
  • This answer was iterated in older question pertaining the subject: https://stackoverflow.com/questions/35412137/how-to-get-access-to-webpack-dev-server-from-devices-in-local-network In my case and probably many other, react is not injecting tags into root, hence a blank page. ``HOST`` change provides no solution – besthost Dec 05 '22 at 19:44