Today, I wanted to update an infrequently updated NodeJS + MongoDB application. It runs tests against MongoDB. However, when re-running the build today, without any changes, my code is unable to connect to the database.
To test, I’ve created mongo-experiments branch that tries to connect and change the database in a before_script
. You can see here the error that is produced:
{ MongoError: failed to connect to server [127.0.0.1:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (/home/travis/build/donejs/bitcentive/node_modules/mongodb-core/lib/topologies/server.js:336:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/home/travis/build/donejs/bitcentive/node_modules/mongodb-core/lib/connection/pool.js:280:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/home/travis/build/donejs/bitcentive/node_modules/mongodb-core/lib/connection/connection.js:189:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
name: 'MongoError',
message: 'failed to connect to server [127.0.0.1:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]' }
Here is the .travis.yml file. I have the following (which, to the best of my understanding, should start mongo).
services:
- mongodb
Here is the script I am running is here. All it is trying to do is connect to the mongo instance:
MongoClient.connect("mongodb://127.0.0.1/bitcentive", function (err, db) {
This works locally.
Any help would be greatly appreciated. Thanks!