1

Using the below code from an example I found, my Heroku Node.js app crashes. It is not responding when I navigate to [myapp].herokuapp.com

var http = require('http');
var port = process.env.PORT || 8000;

var counter = 0;

http.createServer(function (req, res) {

// increment the counter for each visitor request
counter=counter+1;

var path = req.url;
console.log("requested=" + path + " counter=" + counter);

res.writeHead(200, {'Content-Type': 'text/html'}); // prepare response headers

res.end(" :) "); 

}).listen(port);

my procfile is

web: node thenameofmyapp.js

I have done heroku ps:scale web=1

I had some dependencies but removed them to try to get a simple app to work. My current package.json is

{
  "name": "thenameofmyapp",
  "version": "0.0.3",
  "dependencies": {
  },
  "engines": {
    "node": "0.10.x",
    "npm": "1.2.x"
  }
}

Why can't my app bind to the port?

EDIT: It looks like even after multiple updates and running heroku restart, my app is still running code that doesn't exist anymore. What's going on here?

Ivy
  • 887
  • 1
  • 7
  • 25

3 Answers3

1

I'm not completely sure what happened, but it looked like Heroku was not restarting when I pushed new code or ran heroku restart. I created a new app with the same code and it works.

One difference someone else might want to test is that I removed node_packages from my git repo before pushing to the new app.

Ivy
  • 887
  • 1
  • 7
  • 25
1

You can also check what is happening with your app by doing: heroku logs (you have to install the herokucli before).

facundofarias
  • 2,973
  • 28
  • 27
0

This error is most likely caused by a process that is not able to reach an external resource or it has to many code dependencies, or there's to many evaluations, parsing during start.

Dilemmat_Dag
  • 383
  • 1
  • 4
  • 14