Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have full access to a cloud server (running Ubuntu 14.04) via SSH.

I already have installed Node.JS from PPA:

sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js -y
sudo apt-get update
sudo apt-get install nodejs -y

Now, I want to set up my first Node.JS application on my cloud server. It will send a Hello World message from server to client.

require("http").createServer(function (req, res) {
   res.end("Hello World!");


$ node my-script.js

What are the steps to allow users to see this hello world message at a custom domain (e.g.

share|improve this question

closed as off-topic by Sven, mdpc, Ward, Rex, Falcon Momot Jun 8 '14 at 23:48

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – mdpc, Ward, Falcon Momot
  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Sven, Rex
If this question can be reworded to fit the rules in the help center, please edit the question.

What do you mean, "send it to a custom domain"? Do you mean that when a user asks for they'll see your message? – Andrew Schulman Jun 8 '14 at 10:18
@AndrewSchulman When somebody will open in browser will get Hello World! response. – Ionică Bizău Jun 8 '14 at 10:21
OK, then why is your server listening on port 3000? Don't you want 80? – Andrew Schulman Jun 8 '14 at 10:23
@AndrewSchulman Probably. It's the first time when I set up NodeJS on a cloud server. I am getting EACCES error for listen(80). – Ionică Bizău Jun 8 '14 at 10:25
If I start the process with sudo, then it works fine! But, how can I avoid running the process with sudo? – Ionică Bizău Jun 8 '14 at 10:28
up vote 0 down vote accepted


  1. Linked my domain with the server ip adding A record in DNS management:

    Sr No  | Name                   | Destination IP Address | Status    
    3      | |         | Active

    Where Destination IP Address is the ip address used when connecting via ssh:

    $ ssh -A
  2. Redirect 80 port to 3000

    $ sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000

  3. Created a script named index.js containing:

    require("http").createServer(function (req, res) {
       res.end("Hello World!");
  4. Run it using:

    $ node index.js

Then, the response of is Hello World!.

share|improve this answer

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