Meteor error - Storing tasks in a collection [ SOLVED ]


I am following the meteor site tutorial.

But when you add the line:

export const Tasks = new Mongo.Collection('tasks');

I get the following error:

MongoError: failed to connect to server [localhost:27017] on first connect
    at Object.Future.wait (/Users/user/.meteor/packages/meteor-tool/.1.4.1_2.fpzmec++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
    at new MongoConnection (packages/mongo/mongo_driver.js:216:27)
    at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
    at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
    at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
    at new Mongo.Collection (packages/mongo/collection.js:103:40)
    at meteorInstall.imports.api.tasks.js (imports/api/tasks.js:4:14)
    at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
    at Module.require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
    at Module.Mp.import (/Users/user/.meteor/packages/modules/.0.7.6_1.j54juu++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:70:16)
    - - - - -
    at [object Object].<anonymous> (/Users/user/.meteor/packages/npm-mongo/.
    at emitOne (events.js:77:13)
    at [object Object].emit (events.js:169:7)
    at [object Object].<anonymous> (/Users/user/.meteor/packages/npm-mongo/.
    at [object Object].g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at [object Object].emit (events.js:172:7)
    at Socket.<anonymous> (/Users/user/.meteor/packages/npm-mongo/.
    at Socket.g (events.js:260:16)
    at emitOne (events.js:77:13)
Exited with code: 1
Your application is crashing. Waiting for file change.


Are do you start the app? Do you have a MONGO_URL environment variable defined?


I have a variable configured environment. How do I set one? on mac?

But I tried to start an application using:

MONGO_URL = mongodb: // 27017 / tasks meteor run

But of all the same error. :frowning:


How about you just meteor run in the directory of your Meteor application. When you set MONGO_URL environment variable, it means a mongo instance must be already running and the meteor command will not start one for you.


Thank jamgold,

for some reason some db files were with .lock

to solve, I deleted the folder / data / db / and recreated again. He returned to work everything.

Thank you for attention.