node.jsserveripmcafee

How can I access my Express Node.js server through the internet?


I was able to successfully access my node server through a local IP address (192.168.XX.XX) on my WiFi network with the following server code:

var express = require('express');
var app = express();
var server = require('http').createServer(app);

server.listen(8080, "0.0.0.0");

I went to 192.168.XX.XX:8080 and accessed the HTML file successfully.

Specifically, I'm using my phone to access the server but if I get off of the network and use cell service, I can't access the server. I looked up my external IP and got 76.XXX.XXX.XXX. When I go to 76.XXX.XXX.XXX:8080 from my phone (without changing any server code), I can't get to the server. I also tried switching to port 80 in the code and it still didn't work.

I have a McAfee firewall going and I tried to open 8080 to be externally accessible. I also turned the firewall completely off but still couldn't connect.

Any ideas?


Solution

  • The seemingly best solution is using Ngrok. It allows you to expose your local server to the internet. You can download and use it here: https://ngrok.com/