node.js - Error deploying node app to heroku -


i'm relatively new node, , have been having issues deploying node web app heroku... seems have how i'm creating mongoose connection in server file. here error logs i'm getting:

2016-01-06t00:41:30.384170+00:00 heroku[web.1]: state changed starting crashed 2016-01-06t00:43:56.191644+00:00 heroku[web.1]: state changed crashed starting 2016-01-06t00:43:57.774259+00:00 heroku[web.1]: starting process command `node server/server.js` 2016-01-06t00:44:00.138974+00:00 app[web.1]: listening on 4568 2016-01-06t00:44:00.172982+00:00 app[web.1]:  2016-01-06t00:44:00.172992+00:00 app[web.1]: /app/node_modules/mongoose/node_modules/mongodb/lib/server.js:236 2016-01-06t00:44:00.172994+00:00 app[web.1]:         process.nexttick(function() { throw err; }) 2016-01-06t00:44:00.172994+00:00 app[web.1]:                                       ^ 2016-01-06t00:44:00.172995+00:00 app[web.1]: error: connect econnrefused 127.0.0.1:27017 2016-01-06t00:44:00.172996+00:00 app[web.1]:     @ object.exports._errnoexception (util.js:856:11) 2016-01-06t00:44:00.172997+00:00 app[web.1]:     @ exports._exceptionwithhostport (util.js:879:20) 2016-01-06t00:44:00.172998+00:00 app[web.1]:     @ tcpconnectwrap.afterconnect [as oncomplete] (net.js:1063:14) 2016-01-06t00:44:00.968046+00:00 heroku[web.1]: process exited status 1 2016-01-06t00:44:00.983259+00:00 heroku[web.1]: state changed starting crashed 

and here shell of server file:

var express = require('express'); var mongoose = require('mongoose'); var bodyparser = require('body-parser'); var entrycontroller = require('./entries/entrycontroller.js');      var app = express();      app.use(bodyparser.json());     app.use(bodyparser.urlencoded({extended:true}));     app.use(express.static(__dirname + '/../client'));      mongoose.connect('mongodb://localhost');      console.log('listening on 4568');     app.listen(4568); 

any advice appreciated, thanks!

you're trying connect localhost:

mongoose.connect('mongodb://localhost'); 

localhost means "this computer." database not running in same container on heroku node app, instead need connect database hosted.

you may want read tutorial like:

https://scotch.io/tutorials/use-mongodb-with-a-node-application-on-heroku


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -