Search code examples
node.jscurlexpresshostmonster

Can't run express server on hostmonster


I am able to run node.js server on Hostmonster. When I surf to http://node.domain.com, I get the expected html output (where 'domain' is replaced with my actual domain name). Now I wish to get an expressjs server running.

After watching this tutorial for expressjs: https://www.youtube.com/watch?v=FqMIyTH9wSg, I created the exp2014 directory and files, ran the server, and successfully got the initial "Welcome to express" web page returned when I surfed from the command line with: curl http://node.domain.com:3000 from within my Hostmonster account.

The video shows how to set up an express server responding to "localhost:3000", so I adapted the url to my site, as above and ran with curl after ssh to my Hostmonster account.

However, when I try curl http://node.domain.com:3000 from outside my Hostmonster account, the curl command times out. Same thing when I try browsing from chrome or any other browser to http://node.domain.com:3000.

Why is it that the curl command runs successfully from within my Hostmonster account, but I can't browse to it from outside the account (or run the same curl command from outside the account)?


Solution

  • The outside world need access to your express application that is running on your Hostmonster account and in particular on port 3000.

    1. Create a DNS entry for node.domain.com pointing to your server
    2. Make sure that port 3000 is accessible for all incoming requests - this is usually done on the firewall

    The cause of your error is that curl is being blocked from accessing your express application running on a specific port.

    SO1