React application not working on local network

5.7k Views Asked by At

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.

3

There are 3 best solutions below

1
Marcus On BEST ANSWER

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.

1
Caio Amorim On

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.

0
Sravan Kumar On

In case of Ubuntu users, turn off your firewall,

sudo ufw disable