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 net
After running npm start
go to your terminal "bash, cmd ..etc" and run ipconfig
IPv4-Adresse ..... : for example 111.222.333.444
open browser in your second device and type : 111.222.333.444:portNumber
Can you please turn off your firewall and check 192.168.0.5:3000.
Thanks
Sometimes there is another problem for Windows users.
Windows Firewall blocks NodeJs.
Just go to Windows Defender Firewall and click to Allow an app or feature through Windows Defender Firewall and allow Node.js
if you have two machines (lets say pc1 and pc2) and both are connected over the same wifi connection, then:
ipconfig.exe
and unix-like systems type ifconfig
).. you will find the ip address under something:Wireless LAN adapter Wi-Fi
(on windows)wlp5s0
inet Ip_Address
HOST=your_IP npm run start
now, your development machin will be the server that serves the ui over it's IP_Address
In my case, npm run start
used my Ethernet adapter's IP e.g. http://192.168.167.113:3000
but as I was accessing the site using WLAN, I needed to use WLAN IP which was 192.168.0.227
.
Make sure to use WLAN IP with the same port to make it work.
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 !