Fernando Aureliano
Fernando Aureliano

Reputation: 914

NodeJS and Heroku: connect ECONNREFUSED 127.0.0.1:27017

I'm working with a nodejs over heroku using mLab with mongoDB and SailsJS

I'm getting the same issue that are commented here:

https://github.com/balderdashy/sails/issues/2480

(Error: connect ECONNREFUSED 127.0.0.1:27017)

I'm already try all the things that are commented on issue. My connections.js just have one connection configured and I using URI on configuration and set heroku config:set NPM_CONFIG_PRODUCTION=true

herokuMongodbServer: {
adapter: 'sails-mongo',
url: 'mongodb://(redacted)@ds249325.mlab.com:49325/heroku_33gpxp5x',
},

How can I solve the conection at this case?

Thanks!

Upvotes: 0

Views: 1481

Answers (1)

Paul
Paul

Reputation: 36349

it's difficult to troubleshoot from the information provided, but I will say that somewhere in your code you're connecting to Mongo using the default settings rather than the URl you have in your server configuration. Perhaps you're not actually pulling that configuration in all places. If you look in your log, you may get a file and line number from the stack trace that can help you narrow it down. You might need to do heroku logs -n 500 to get a long (500-long) list of log messages.

As a side-note, you're usually better off pulling the URL from the environment (Heroku sets environment variables like MONGO_URI or similar depending on which plugin you use that you can access via process.env.MONGO_URI or similar).

Upvotes: 2

Related Questions