0

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?

HymnZzy
  • 2,669
  • 1
  • 17
  • 27
Bhavin S.
  • 77
  • 12
  • 2
    well.. did you write custom code or did you use the node `http-server` command on a shell? If it is a custom server you wrote.. please do share at least SOME of the code so we can understand what's going on – The Bomb Squad Nov 24 '20 at 11:23
  • I got the project from git and make some changes according to my requirement. I go to the project directory and then write the command npm start. The project runs fine in http://localhost:8080/ but I want to show this running project to my senior on their pc. – Bhavin S. Nov 24 '20 at 11:26
  • well now i know it's custom made server(not a node problem) and the only thing i can think up of is that your personal computer has some security against that.. if you do know where the server file is.. pls send its content so we can see (another highly likely option is that the server chooses to `listen` specifically to localhost:8080) – The Bomb Squad Nov 24 '20 at 11:33
  • I have installed webpack-dev-server for my project – Bhavin S. Nov 24 '20 at 12:05

4 Answers4

1

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/

HymnZzy
  • 2,669
  • 1
  • 17
  • 27
1

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
Java-Dev
  • 438
  • 4
  • 20
1

Your localhost IP address is 127.0.0.1

You should try - 127.0.0.1:8080

all the best !!!

Debasis Das
  • 549
  • 3
  • 8
0

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

Deep
  • 532
  • 3
  • 10