3

I’m trying to view a CreateReactApp project from a different device. I tried setting the host to 0.0.0.0 by setting the “start” script to:

"start": "cross-env HOST=0.0.0.0 react-scripts start".

Though the console did log

Attempting to bind to HOST environment variable: 0.0.0.0
If this was unintentional, check that you haven't mistakenly set it in your 
shell.
Learn more here: [URL BLOCKED BY GITHUB].

I could not access this project from another device on the same network using the computer’s IP.

At the same time I managed to access other projects (from a “tomcat” local server) on the same computer from the same device using the computer's IP. Any idea why this might be happening? My environment: Windows10. I tried it on both ‘PowerShell’, and ‘Bash on Ubuntu on Windows (WSL)’, on more than one Create-React-App project.

Ben Carp
  • 24,214
  • 9
  • 60
  • 72

2 Answers2

2

By default, Create React App serves the app in localhost:3000. So accessing <ip address of machine serving the app>:3000 should work for devices in the same network.

Revert the change in start script in package.json and open the app in <ip adress>:3000

sudo bangbang
  • 27,127
  • 11
  • 75
  • 77
2

Windows Defender Firewall was blocking the connection. It had a blocking rule for "NodeJs: Server Side JavaScript". To open the connection:

Settings => Update and Security => Windows Security => Firewall and network protection => Advanced Settings => Inbound rules => remove rules blocking node server.

Windows did not show a notification when blocking. It might be that at some point for some reason I authored it to block a connection to the nodeJS server.

Ben Carp
  • 24,214
  • 9
  • 60
  • 72
  • I also discovered that Windows (10) was blocking Node by the firewall. I resolved it by accessing `Windows Defender Settings => Allow an app through the firewall`. Then in the list of apps find `Node.js Server-side JavaScript` (There may be a few). Ensure the checkbox for `Private` is ticked and then click 'OK' – Jackson Sep 14 '18 at 07:20