How to open a create-react-app from another computer connected to the same network?

I am using create-react-app and hosting in its default port localhost:3000 and want to access this from another device on the same network.

I got the IP of my host's IP (using ifconfig) 192.168.0.5 and tried opening 192.168.0.5:3000 but that did not work.

Is there any way to achieve this?


Solution 1:

Simply run HOST=0.0.0.0 npm run start.
Afterwards open the url from another device on the network.

In your case, 192.168.0.5:3000 would work.

Documentation for setting HOST environment variables.

Solution 2:

As I can't post comment, In complementary to Elad if you have react-scripts start instead of npm run start

HOST=0.0.0.0 react-scripts start

Works too !

Solution 3:

If you are on Ubuntu, simply run

$> sudo ufw allow 3000

Then access your app using your internal ip from local network. to get your local IP run:

$> ifconfig