Opening ports on a mac-mini, works locally, not on the LAN

3

I have my mac mini running a nodejs server on port 8000. On the mac, I can hit it at 127.0.0.1:8000/something. I get back a "hello world" type of response.

On the same network, from a different machine, I cannot hit this server on the mac. I am getting time outs. I have been pulling my hair out trying to understand why.

  1. I check the machine on the local net. For instance 192.168.1.7:8000 should resolve to that machine and port from another machine. Times out.

  2. I have a NAS admin page sitting at 192.168.1.200:5000 (sorry about that typo before) and it resolves beautifully. Port 5000 is forwarded to the NAS from the router.

  3. I have set up the firewall rules (on the router) in exactly the same way for nodejs as I did for the NAS. The NAS is available outside of my network via a router rule and a no-ip dynamic DNS mapping. The nodejs server is forwarded the same way. No dice, times out.

Any thoughts? I have no firewall (that I can detect) on the mac. I can see the server listening to 8000 on the mac. It works locally.

What am I doing wrong here?

UPDATES with answers to questions.

Thank you all for the feedback, Here are the answers to your questions.

Output from netstat.

netstat -anp tcp | grep 8000

tcp4       0      0  *.8000                 *.*                    LISTEN

I do not have the mac firewall running (at least in the system settings I mean). I have seen posts about something called IPFW, but I have no idea what that is.

On the mac, when I hit 192.168.1.7:8000 I get:

Hello World

My understanding of nodejs is that I just "bind it" to a port. Here is the code, right out of their example.

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8000);

console.log('Server running at http://127.0.0.1:8000/');

JuddGledhill

Posted 2012-03-12T17:13:15.353

Reputation: 43

2I think 198.162.1.200 is a typo. If so, please fix. Also, please edit your question to include the output of netstat -anp tcp | grep 8000 on the host that's running nodejs, which will show the state of listening and active TCP connections on port 8000. – Kyle Jones – 2012-03-12T18:17:52.293

Factor out the router and the network. Try to access the service from the Mac locally using the exact same URL as you try to use with other machines on the LAN. It's possible the service is just bound to 127.0.0.1 and not the LAN IP. – David Schwartz – 2012-03-12T20:05:04.580

Did you open the port on OS X's built-in firewall as well? Also when you started the server, did you set it to listen to 0.0.0.0 as opposed to 127.0.0.1? – billc.cn – 2012-03-12T20:31:50.090

Answers

2

I have an similar issue.

I found it is not helpful by changing firewall options(even disable firewall entirely) to enable the node access from outside on MAC OS X, at least, not work in my case.

My solution is to change the host name which bound with the node.js server:

  • use '0.0.0.0' as host name to allow access from outside
  • use 'localhost' with local access only

I guess 'localhost' used as the default value somehow, and hope this tip is helpful to others.

Cheers

user291528

Posted 2012-03-12T17:13:15.353

Reputation: 21

0

My machine is currently configured thusly:

  • The firewall is off - I am behind a hardware router that is locked down.
  • All sharing is off in the system prefs.
  • I have a static IP address (network prefs : "using DHCP with manual address").
  • My server is still the same, it is running on port 8000.

I am now able to hit it from inside the LAN and outside with my no-IP domain. I think it was the static addressing thing personally - though I am not 100% sure.

JuddGledhill

Posted 2012-03-12T17:13:15.353

Reputation: 43

is there any luck for you yet? Stuck up with exactly the same issue. – Futur – 2012-03-29T13:28:33.637

0

Still I'm not convinced with a proper solution for this but, To make it work i simply did this,

  1. Start your Mac OSX default web server and in the index.html,
  2. Add a redirection code in it which will point to your node js port, and you can access the same from outside LAN systems as well.

Actually,This will not be the scenario when you host it so you can take the above approach and still work on it without a block,

Futur

Posted 2012-03-12T17:13:15.353

Reputation: 133

I think that a redirect would mean that the node "backend server" is out on the net and every request from a client side service would incur 2 requests to my little mac...I am trying to "shield" it in the context of another server. – JuddGledhill – 2012-03-30T18:25:30.437