Application Error when attempting to deploy Node.js/Express/Socket.io application on Heroku

后端 未结 5 646
甜味超标
甜味超标 2021-02-03 11:19

I am fairly new to all of these technologies (including somewhat JavaScript) so you might have to bear with me here.

I followed the ChatApp tutorial over at Socket.IO do

相关标签:
5条回答
  • 2021-02-03 11:19

    Disclosure: I'm the Node Platform Owner at Heroku

    First, you should run heroku logs to get logging output.

    Second, do you mean to have commented out listen on your server? Without this, your server won't allow any incoming connections:

    // http.listen(3000, function(){ // console.log('listening on *:3000'); // });

    Finally, instead of binding to a hardcoded port (3000), you should bind to an environment variable with a default:

    http.listen(process.env.PORT || 3000, function(){ console.log('listening on', http.address().port); });

    0 讨论(0)
  • 2021-02-03 11:19

    Check all your dependency. You could confirm it by cross checking your package.json or rather do refresh installation of all the dependencies in your package.json

    0 讨论(0)
  • 2021-02-03 11:34

    I encountered the same error, but including "start":"node app.js" in package.json file tends to fix the problem. Hope this helps anyone that encounters the same error.

    Note: app.js should be your own main server file.

    0 讨论(0)
  • 2021-02-03 11:34

    After checking heroku logs I was able to find out that my bcrypt dependency defined properly in package.json. I would recommend you:

    1. Check that your dependencies have the right versions attached to them.
    2. Delete node_modules file
    3. Run npm install
    4. Check if all the dependencies installed properly
    5. If they have installed properly, then git push heroku
    0 讨论(0)
  • 2021-02-03 11:43

    I also encountered this error after not using my Node app for several weeks. The reason appeared to be that not only had the app gone to sleep, but the database and its connection had too. I'm using a free MongoDB instance hosted by MongoLab.

    I fixed this by running my local copy of the app, causing MongoLab to awaken. Then after a few minutes, my Heroku-hosted app started working again.

    0 讨论(0)
提交回复
热议问题