Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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/');
share|improve this question
2  
I 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 Mar 12 '12 at 18:17
    
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 Mar 12 '12 at 20:05
    
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 Mar 12 '12 at 20:31
add comment

3 Answers

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

share|improve this answer
add comment

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.

share|improve this answer
    
is there any luck for you yet? Stuck up with exactly the same issue. –  Futur Mar 29 '12 at 13:28
add comment

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,

share|improve this answer
    
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 Mar 30 '12 at 18:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.