0

I'm trying to run a node.js app on heroku, it runs fine using npm start and using heroku locally, but does not run when hosted on heroku. I have looked through all the solutions i could find, the remote mongodb database works fine when run using npm start, my port is set up correctly, have restarted heroku and dynamos a bunch of times, and I have a procfile with the following:

web node index.js

The following is the console messages I get:

Starting process with command `node index.js`
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Application ready to serve requests.
Environment: production
app[web.1]: (node:4) DeprecationWarning: `open()` is deprecated in 
mongoose >= 4.11.0, 
use `openUri()` instead, or set the `useMongoClient` option if using 
`connect()` 
or `createConnection()`. See 
http://mongoosejs.com/docs/connections.html#use-mongo-client
Db.prototype.authenticate method will no longer be available in the 
next major
release 3.x as MongoDB 3.6 will only allow auth against users in the 
admin db 
and will no longer allow multiple credentials on a socket. Please 
authenticate using MongoClient.connect with auth credentials.
DB Connection Open...
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 
60 seconds of launch
Stopping process with SIGKILL
Process exited with status 137

This is my package.json:

{
  "name": "shop",
  "version": "0.1.0",
  "description": "eCommerce Site",
  "author": "Slav Bugryn",
  "main": "index.js",
  "scripts": {
    "test": "grunt test",
    "build": "grunt build",
    "all": "npm run build && npm run test",
    "start": "node server.js"
  },
  "dependencies": {
    "connect-flash": "^0.1.1",
    "construx": "^1.0.0",
    "construx-copier": "^1.0.0",
    "construx-dustjs": "^1.1.0",
    "construx-less": "^1.0.0",
    "dust-makara-helpers": "^4.2.0",
    "dustjs-helpers": "^1.7.3",
    "eslint": "^4.12.1",
    "express": "^4.12.2",
    "express-messages": "^1.0.1",
    "kraken-js": "^2.0.0",
    "makara": "^2.0.3",
    "mongodb": "^2.2.33",
    "mongoose": "^4.13.6",
    "requirejs": "^2.3.5"
  },
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-cli": "^1.2.0",
    "grunt-config-dir": "^0.3.2",
    "grunt-contrib-clean": "^1.1.0",
    "grunt-contrib-less": "^1.4.1",
    "grunt-contrib-requirejs": "^1.0.0",
    "grunt-copy-to": "0.0.12",
    "grunt-dustjs": "^1.4.0",
    "grunt-eslint": "^20.1.0",
    "grunt-makara-amdify": "^1.0.1",
    "grunt-mocha-cli": "^3.0.0",
    "mocha": "^4.0.1",
    "supertest": "^3.0.0"
  },
  "directories": {
    "lib": "lib",
    "test": "test"
  },
  "keywords": [],
  "license": "ISC"
}

Any advice would be greatly appreciated, thanks in advance.

SBugryn
  • 49
  • 3
  • Dude did you set your port to bind to the environment variable of heroku 'process.env.PORT'? – Mo Hajr Dec 04 '17 at 20:27
  • I have a server.js file that contains the following: `server = http.createServer(app); server.listen(process.env.PORT || 8000); server.on('listening', function () { console.log('Server listening on http://localhost:%d', this.address().port); });` Thanks for your reply. – SBugryn Dec 04 '17 at 21:57
  • Now I am getting this error: `at=error code=H20 desc="App boot timeout" method=GET path="/" ` – SBugryn Dec 04 '17 at 22:08
  • Figured it out! I sent the Procfile to the wrong place, after fixing that I got another error which i fixed by running grunt build (had to use --force too). – SBugryn Dec 05 '17 at 00:04

1 Answers1

0

Figured it out! I sent the Procfile to the wrong place (had to go to server.js, which i found out by looking in package.json and finds start under scripts), after fixing that I got another error (same as here, where i also got the fix: Got a internal server error after I deploy my node js project to the host) which i fixed by running grunt build (had to use --force too).

SBugryn
  • 49
  • 3