Bhavin S.
Bhavin S.

Reputation: 77

My node.js project run on http://localhost:8080/ but not run on my local ip 192.168.1.139:8080

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?

Upvotes: 0

Views: 1794

Answers (4)

Deep
Deep

Reputation: 549

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

Upvotes: 0

Debasis Das
Debasis Das

Reputation: 569

Your localhost IP address is 127.0.0.1

You should try - 127.0.0.1:8080

all the best !!!

Upvotes: 1

Java-Dev
Java-Dev

Reputation: 458

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

Upvotes: 1

HymnZzy
HymnZzy

Reputation: 2925

192.168.1.139:8080 is not a localhost IP address. Try 127.0.0.1:8080 instead.

If you want to make this accessible on the internet you'll need to tunnel it, try https://ngrok.com/

Upvotes: 1

Related Questions