My node.js project run on http://localhost:8080/ but not run on my local IP 192.168.1.139:8080
Actually, I am new in node.js. I have tried to search for information on google but could not get any solution.
Can anyone please help me?
My node.js project run on http://localhost:8080/ but not run on my local IP 192.168.1.139:8080
Actually, I am new in node.js. I have tried to search for information on google but could not get any solution.
Can anyone please help me?
On
You should have one file called "web.bat" in your project class-path. You need to configure your PC IP address in that file. You can set the port number also in this file if you want to use some other port.
webpack-dev-server --inline --port 8080 --host 192.168.1.139
On
webpack-dev-server has a host option to make the server available on the ipv4 address.
You could set the host to 0.0.0.0
https://webpack.js.org/configuration/dev-server/#devserverhost
npx webpack serve --host 0.0.0.0
The option is similar for other servers. There have also been other questions asked for it: How to allow access outside localhost
For more context:
https://www.howtogeek.com/225487/what-is-the-difference-between-127.0.0.1-and-0.0.0.0/
In the context of servers, 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs
192.168.1.139:8080is not a localhost IP address. Try127.0.0.1:8080instead.If you want to make this accessible on the internet you'll need to tunnel it, try https://ngrok.com/