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=
Things I had to do (didn't have to scale or use Express)..
Create a Procfile in the root directory (a file literally called Procfile, no extension).
Inside Procfile, type:
Add a script and engine to package.json
Update port in server.js
And why..
To explicitly declare what command should be executed to start your app. Heroku looks for a Procfile specifying your process types
For the script, if no Procfile is present in the root directory during the build process, your web process will be started by running npm start. For the engine, to specify a Node version that matches the runtime you’re developing with and want to use on Heroku.
Heroku already assigns your app a port and adds it to the env, so you can't set the port to a fixed number.
Resources:
https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
https://devcenter.heroku.com/articles/deploying-nodejs
Have you scaled the heroku app?
This is a required step. The
1
is the number of processes you want spawned for your app.Change your port
from
to
What's inside your Procfile? Does it match your app name?