Thursday, 27 April 2017

Node.JS app is not running on heroku

I have made a basic application in Node.JS. I am trying to deploy it on heroku server which is successfully deployed.

I am able to access this application on localhost however it is not running on heroku server. It tries to start then it kills automatically.

index.js

var http = require("http");   
http.createServer(function (request, response) {

   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});

   // Send the response body as "Hello World"
   response.end('Hello World\n');
}).listen(80);

package.json

{
  "name": "powerful-escarpment",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "author": "",
  "license": "ISC"
}

server.logs

2017-04-27T15:05:52.119923+00:00 heroku[web.1]: State changed from crashed to starting
2017-04-27T15:05:53.414613+00:00 heroku[web.1]: Starting process with command `npm start`
2017-04-27T15:05:56.563672+00:00 app[web.1]: 
2017-04-27T15:05:56.563686+00:00 app[web.1]: > powerful-escarpment@1.0.0 start /app
2017-04-27T15:05:56.563687+00:00 app[web.1]: > node index.js
2017-04-27T15:05:56.563687+00:00 app[web.1]: 
2017-04-27T15:05:56.836819+00:00 heroku[web.1]: Process exited with status 0
2017-04-27T15:05:56.849642+00:00 heroku[web.1]: State changed from starting to crashed



via Williams

No comments:

Post a Comment