Search code examples
node.jsmongodbheroku

Heroku/Nodejs Failing to launch, at=error code=H10 desc="App


I know this has been asked a few times but I haven't been able to find a solution that works yet. I'm trying to have my node server deployed on Heroku and build succeeds but the log prints the following message. I'm also using mongoose and have no problem deploying locally.

2019-02-10T22:30:09.912634+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=chatifydotcom.herokuapp.com request_id=b486e511-ff21-4166-ae1d-07bf5796691e fwd="74.196.2.211" dyno= connect= service= status=503 bytes= protocol=https

2019-02-10T22:30:10.287542+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=chatifydotcom.herokuapp.com request_id=18f17ca0-56df-4dfe-a560-d890a699f17f fwd="74.196.2.211" dyno= connect= service= status=503 bytes= protocol=https

Server.js

 const uri = process.env.MONGODB_URI || "mongodb://localhost:27017/chat"
mongoose
  .connect(uri, { useNewUrlParser: true })
  .then(() => console.log("MongoDB Connected"))
  .catch(err => console.log(err.message))

    const port = process.env.PORT || 9000
server.listen(port, () => {
  console.log(`This server is over ${port}`)
})

Solution

  • I'm working on this same error right now. The Heroku error code H10 essentially just means the app crashed, as it says, but you need to do more digging to figure out what the actual problem is.

    You can do that by starting app on a heroku dyno from the console: EDIT: command for running the console may vary, I did this on Windows

    heroku run bash
    npm start
    

    Then you can see the console output of your app, and more specific error info for troubleshooting. Then you can fix or ask a more specific question on here.