node.jsserverwebserverstatic-ip-address

How to host my node server using own pc over public static ip?


I hava a broadband internet connection with public static ip address which is connected to my wifi router. Multiple devices, specially my pc is connected to that wifi router. Now I want to run a node application in 3000 port in my pc and expose that for public use.

For example my public ip is 103.80.x.y which is connected to my wifi router and my pc is connected to wifi router so got a private ip 192.168.a.b from router.I can access the node application from other device connected to same router using 192.168.a.b:3000. But now I want to access my node application by visiting 103.80.x.y:3000 from anywhere outside by connecting to internet. How can setup this system from my windows pc?


Solution

  • Set up port forwarding on your router. This tells the router to direct incoming traffic on a specific port to your computer's local IP address. Just google your router's name + 'port forwarding' and you'll find a tutorial. Follow that tutorial and fill in port 3000 when you're asked what port you want to forward.

    Also you should adjust your computer's firewall to allow incoming connections on the port your app is using.

    The basic idea is this: When someone tries to access your public IP on the specified port, your router will receive that request. Thanks to port forwarding, it'll know to send that traffic to your computer's local IP. Your computer's firewall will allow this traffic, and your app will receive and respond to the request.