Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js: Simple app not working on Heroku

I've written a basic node.js application and I've managed to deploy it on Heroku without having any problem. I've created my package.json and Procfile, however from logs I see that there is no running processes, thus cannot get any response. What could be the problem?

PS: I do not want to use the Express framework

My Code:

var http = require("http");

http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World");
  response.end();

  console.log("I am working");
}).listen(8888);

My package.json:

{
  "name": "node-example",
  "version": "0.0.1",
  "dependencies": {
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}

Logs:

2012-10-22T12:36:58+00:00 heroku[slugc]: Slug compilation started
2012-10-22T12:37:07+00:00 heroku[slugc]: Slug compilation finished
2012-10-22T12:40:55+00:00 heroku[router]: Error H14 (No web processes running) -> GET aqueous-bastion-6914.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-10-22T12:50:44+00:00 heroku[router]: Error H14 (No web processes running) -> GET aqueous-bastion-6914.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
like image 535
Ali Avatar asked Oct 22 '12 12:10

Ali


People also ask

Why is my app not working on Heroku?

There are some errors which only occur when the app is rebooting so you will need to restart the app to see these log messages appear. For most apps, we also recommend enabling one of the free logging addons from https://elements.heroku.com/addons#logging to make sure that your historical log data is being saved.

Why is my Heroku build failing?

Sometimes installing a dependency or running a build locally completes successfully, and when it gets to Heroku, the build will fail. If you run into an issue where a dependency only fails on Heroku, it's recommended to spin up a one-off dyno to debug the script.

Does Heroku automatically npm install?

Heroku by default installs only the production dependencies, ignoring the development dependencies under devDependencies .


2 Answers

Have you scaled the heroku app?

$ heroku ps:scale web=1

This is a required step. The 1 is the number of processes you want spawned for your app.

like image 178
J. K. Avatar answered Sep 17 '22 17:09

J. K.


Change your port

from

.listen(8888)

to

.listen(process.env.PORT || 8888)
like image 24
jwchang Avatar answered Sep 18 '22 17:09

jwchang