A simple node.js server working locally but not at heroku

A simple server written that listens on port 3000 for / request and prints Hello World\n:

iamfaiz@HP /f/projects
$ mkdir nodeapp

iamfaiz@HP /f/projects
$ cd nodeapp/

iamfaiz@HP /f/projects/nodeapp
$ touch package.json

iamfaiz@HP /f/projects/nodeapp
$ touch app.js

iamfaiz@HP /f/projects/nodeapp
$ touch Procfile

iamfaiz@HP /f/projects/nodeapp
$ node app.js
Listening at port 3000

app.js

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3000, '127.0.0.1');
console.log('Listening at port 3000');

package.json

{
  "name": "SimpleNodeApp",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Faiz Ahmed <iamfaizahmed123@gmail.com> (http://google.com/)",
  "license": "ISC"
}

Procfile

web: node app.js

Simple directory structure all files in the root:

Directory structure

After initializing and committing to git repository:

$ git push heroku master
Initializing repository, done.
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (8/8), 915 bytes | 0 bytes/s, done.
Total 8 (delta 1), reused 0 (delta 0)

-----> Node.js app detected

       PRO TIP: Specify a node version in package.json
       See https://devcenter.heroku.com/articles/nodejs-support

-----> Defaulting to latest stable node: 0.10.32
-----> Downloading and installing node
-----> Exporting config vars to environment
-----> Installing dependencies
       npm WARN package.json SimpleNodeApp@1.0.0 No description
       npm WARN package.json SimpleNodeApp@1.0.0 No repository field.
       npm WARN package.json SimpleNodeApp@1.0.0 No README data
-----> Cleaning up node-gyp and npm artifacts
-----> Building runtime environment
-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 5.4MB
-----> Launching... done, v3
       http://tranquil-reaches-1850.herokuapp.com/ deployed to Heroku

To git@heroku.com:tranquil-reaches-1850.git
 * [new branch]      master -> master

iamfaiz@HP /f/projects/nodeapp (master)
$ heroku open
Opening tranquil-reaches-1850... done

You can see it for yourself: https://tranquil-reaches-1850.herokuapp.com/

You must not listen on 127.0.0.1 but on 0.0.0.0

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

I also recommend you to get the port to listen in the env variable like this:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(process.env.PORT, '0.0.0.0');