0

Ok, I have searched for hours on this, nothing is working the way it should so I have to be doing something wrong. It works fine on localhost:port but I can't get it to work remotely.

Here is the app.js

var http = require('http');
var express = require('express');
var app = express();

app.set('view engine', 'jade');
app.set('views', './views');

app.get('/', function(req, res) {
  res.render('index', {title: 'Welcome', message: 'Hello ExpressJS!'});
});

app.listen(3000);
console.log('Running Express...');

Here is my port fowarding configuration:

Name: HTTP
Service Type: TCP
External Starting Port: 80
External Ending Port: 80
Use the same port range for Internal Port: [Checked]
Internal IP Address: 192.168.1.11 (This is the pc I want to use)

DNS Configuration

Name: Blank Type: A TTL: 300 Target: My Ip Address
Name: WWW Type: A TTL: 300 Target: My Ip Address

If I use the www.mydomain.com I get nothing, If I use my IP address still nothing. I unchecked Use same internal port, from the port forwarding and entered 3000 but it didn't do anything either, kept causing errors.

How can I make my node js server public?

Seva
  • 1

1 Answers1

1

Your port forwarding only references port 80, but your server is on port 3000 so the port forwarding is never getting to your server process. You have several options to fix:

  1. You can forward port 80 on your router IP to port 3000 on 192.168.1.11 and then you would access port 80 on your public IP address and the incoming port 80 traffic would be forwarded to port 3000 on your server.

  2. You can forward port 3000 on your router IP to port 3000 on 192.168.1.11 and then you would access port 3000 on your public IP address and the incoming port 3000 traffic would be forwarded to port 3000 on your server.

  3. You can forward port 80 on your router IP to port 80 on 192.168.1.11 and then you would access port 80 on your public IP address and you would change your server to run on port 80 and the incoming port 80 traffic would be forwarded to port 80 on your server.

First, worry about getting it working using your public IP address. Then, once that works, you can test/configure your DNS entry for that public IP address.

Other things to consider on Windows:

  1. There may be other servers running already on some ports so you have to make sure you're not conflicting with existing port usage.

  2. The Windows firewall protecting your local computer may need to be configured to allow the incoming connection to your server (or you can temporarily turn it off, not recommended to leave it off).

jfriend00
  • 155
  • Ok, method 1, I don't know how to do that, my router doesn't seem to have the option. Method 2. I tried port forwarding 3000 and when I type my ipaddress into the browser, It does nothing. Method 3, If I try to run node on port 80 it give that error Error: listen EACCES 0.0.0.0:80 and I believe that means it can't run on that port. I don't think I have any server running or anything running on port 80 besides the app.js. – Seva Aug 18 '17 at 07:56
  • For method 2, when you typed your IP address into the browser, did you specify port 3000 in the URL as in http://xxx.yyy.zzz:3000? For method 3, the EACCES error is probably because you need elevated privileges to run a server on port 80 (on Linux). – jfriend00 Aug 18 '17 at 07:58
  • @JoshBeyer - For method 1, I've never seen a router that couldn't do port forwarding from port x to port y - that's a very common feature, even in low-end consumer routers. – jfriend00 Aug 18 '17 at 08:06
  • for method 2, yes. It says it can't reach this page. Method 3, this is being tested on windows 10 through the developer mode Ubuntu Bash – Seva Aug 18 '17 at 08:06
  • @JoshBeyer - EACCES could also be because there's already a server running on that port. In Windows, you may also have to open the Windows firewall on that port to allow incoming connections to the computer or disable the local computer's firewall (not recommended except for testing). – jfriend00 Aug 18 '17 at 08:08
  • Here is the router page, I don't see the option to forward from x to y. I tried unchecking that box and typing in 3000 but that doesn't work. http://imgur.com/a/rkmI6 and here is the other http://imgur.com/a/GRrQD – Seva Aug 18 '17 at 08:09
  • @JoshBeyer - It looks like you select your node server rule on the left and then hit "Edit Service" and it should give you options for editing the ports. It looks to me like it will support forwarding X to Y. I know that a low-end Netgear router from 10 years ago support this. – jfriend00 Aug 18 '17 at 08:12
  • UPDATE, turning off firewall worked, for opening port 3000. But, I have to type in myip:3000 or mydomain.com:3000 – Seva Aug 18 '17 at 08:12
  • @JoshBeyer - Now, you just need to change the port forwarding to forward incoming 80 to your 3000 and then you can just type http://myip. – jfriend00 Aug 18 '17 at 08:13
  • Hm.. So on the Node Server service, External starting port should be 80, and external ending port should be 3000. What do I do with the check box to enable internal same as external? – Seva Aug 18 '17 at 08:15
  • @JoshBeyer - Honestly, I don't understand what they mean by external starting/ending and internal starting/end? I'd suggest reading the help files for that screen that netgear provides. My routers only have two port options: incoming source port and destination port. You want the incoming port to be 80 and have that forwarded to 3000 on your local IP. – jfriend00 Aug 18 '17 at 08:16
  • Alright, I will check that and try to solve it. Thank you for all your help. – Seva Aug 18 '17 at 08:17
  • I got it to work with these settings http://imgur.com/a/55Tzr – Seva Aug 18 '17 at 10:58