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.
If you are on windows and the above solutions don't work, it is most probably a firewall issue. You can try looking in Allowed Applications in Control Panel, to check if node is allowed on private networks. Or looking in the Windows Defender Firewall with Advanced Security and checking the Monitoring\Firewall tab and check for Node.js.
if you have two machines (lets say pc1 and pc2) and both are connected over the same wifi connection, then:
bind your create-react-app development server to your Wireless LAN adapter wi-fi IPv4 address (on windows type the command ipconfig.exe and unix-like systems type ifconfig).. you will find the ip address under something:
Wireless LAN adapter Wi-Fi (on windows)
wlp5s0inet Ip_Address
in your sheel where you develop react run HOST=your_IP npm run start
now, your development machin will be the server that serves the ui over it's IP_Address
Step:1 - In webpack.config.js change host to "host: '0.0.0.0'",
Step:2 - npm run start,
Step:3 - run ipconfig and replace your ipv4 with http://192.168.X.X:3000,
In case it won't work add allow Nodejs in firewall and add Inbound rule with port 3000
As someone else already mentioned, it's possible that React is just giving you the wrong IP address. In my case, React was pulling from one of my VMWare ethernet adapters. To open the right one, type ipconfig in Command Prompt and use the IPv4 Address listed under "Wireless LAN adapter Wi-Fi" or your actual ethernet adapter.
at the end of 2021 was doing several react projects via tutorials at that time when i started apps, it was showing 2 links with localhost and ip address link and 2nd link was for devices it the same network. and now (18 may 2022) when i wanted to make react app independently, when i am starting my react app its giving link with localhost. in my case (windows 11) try http://yourComputerIp:portNumber
to get ip on windows type ipconfig in cmd and your ip address will be under name IPv4 Address