Search code examples
reactjslocalhostipip-addresslocal-network

React application not working on local network


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.


Solution

  • 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.