admin管理员组

文章数量:1023744

I just created a new react app using create-react-app. when I tried access the app from another pc on the same lan, it seems to be loading but doesn't shows up.
I am able to view the static files with no problem.
Thanks for your help.

Update: Tried on other lan network and it's working! what can be the reason it doesn't work on the first lan?

I just created a new react app using create-react-app. when I tried access the app from another pc on the same lan, it seems to be loading but doesn't shows up.
I am able to view the static files with no problem.
Thanks for your help.

Update: Tried on other lan network and it's working! what can be the reason it doesn't work on the first lan?

Share Improve this question edited Mar 1, 2019 at 11:33 Zohar Golan asked Mar 1, 2019 at 8:57 Zohar GolanZohar Golan 511 gold badge1 silver badge7 bronze badges 2
  • Inspect network and console to provide more insights into your problem. – Apolo Commented Mar 1, 2019 at 9:12
  • It seems that the browser is pending for the bundle.js nothing on console... – Zohar Golan Commented Mar 1, 2019 at 9:15
Add a ment  | 

3 Answers 3

Reset to default 1

See the Create-React-App docs:

HOST:
By default, the development web server binds to localhost. You may use this variable to specify a different host.

Set the HOST environment variable (in .env or in your shell) to 0.0.0.0 to bind to every address and you should be off to the races.

You have to make sure that the port 3000 is open on your machine (or any other that you use).

In addition, you can try to serve application on 0.0.0.0 host instead of localhost.

To access your localhost react dev server on another puter on the same LAN you need to know the LAN IP of the host puter where the react dev server is running. On mac you can find the ip here: System Preferences > Network > Advanced > TCP/IP. It is either the IPv4 or IPv6 address.

Just replace localhost with the IP address when accessing the server with the other puter.

For example: localhost:3000 > 192.168.1.179:3000

I just created a new react app using create-react-app. when I tried access the app from another pc on the same lan, it seems to be loading but doesn't shows up.
I am able to view the static files with no problem.
Thanks for your help.

Update: Tried on other lan network and it's working! what can be the reason it doesn't work on the first lan?

I just created a new react app using create-react-app. when I tried access the app from another pc on the same lan, it seems to be loading but doesn't shows up.
I am able to view the static files with no problem.
Thanks for your help.

Update: Tried on other lan network and it's working! what can be the reason it doesn't work on the first lan?

Share Improve this question edited Mar 1, 2019 at 11:33 Zohar Golan asked Mar 1, 2019 at 8:57 Zohar GolanZohar Golan 511 gold badge1 silver badge7 bronze badges 2
  • Inspect network and console to provide more insights into your problem. – Apolo Commented Mar 1, 2019 at 9:12
  • It seems that the browser is pending for the bundle.js nothing on console... – Zohar Golan Commented Mar 1, 2019 at 9:15
Add a ment  | 

3 Answers 3

Reset to default 1

See the Create-React-App docs:

HOST:
By default, the development web server binds to localhost. You may use this variable to specify a different host.

Set the HOST environment variable (in .env or in your shell) to 0.0.0.0 to bind to every address and you should be off to the races.

You have to make sure that the port 3000 is open on your machine (or any other that you use).

In addition, you can try to serve application on 0.0.0.0 host instead of localhost.

To access your localhost react dev server on another puter on the same LAN you need to know the LAN IP of the host puter where the react dev server is running. On mac you can find the ip here: System Preferences > Network > Advanced > TCP/IP. It is either the IPv4 or IPv6 address.

Just replace localhost with the IP address when accessing the server with the other puter.

For example: localhost:3000 > 192.168.1.179:3000

本文标签: javascriptCant view React app on lan from another pcStack Overflow