Question

I am trying to start a project with nodejs on a windows machine. I know that windows isn't the right environment but that's what I use!

I run into an error while starting my server with compound server 8888. I generated all files through

compound init photo --tpl jade --css less --db mongodb
cd photo
npm install -l
compound generate crud album title images createdAt:date

After i realized that you can install compound as compound or compoundjs, this generation worked well (with compoundjs installed it didnt work but when I installed compound it worked - i thought it is both the same :-/).

But when I try to start the server with compound server 8888 it breaks with this error:

Compound server listening on 0.0.0.0:8888 within development environment

{PATH}\photo\node_modules\jugglingdb-mongodb\lib\mongodb.js:74
        if (err) throw err;
                       ^
Error: failed to connect to [localhost:27017]
    at Server.connect.connectionPool.on.server._serverState ({PATH}\photo\node_modules\jugglingdb-mongodb\node_modules\mongodb\lib\mongodb\connection\server.js:564:74)
    at EventEmitter.emit (events.js:126:20)
    at connection.on._self._poolState ({PATH}\photo\node_modules\jugglingdb-mongodb\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:124:15)
    at EventEmitter.emit (events.js:99:17)
    at Socket.errorHandler ({PATH}\photo\node_modules\jugglingdb-mongodb\node_modules\mongodb\lib\mongodb\connection\connection.js:465:10)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Apparently it cant connect to the MongoDB but why? Did I have to start this db somewhere like MySQL?

Any help would be appreciated.
Thank you!

Was it helpful?

Solution

You need to start MongoDB daemon first. To do that, go the directory where your MongoDB files reside and run mongod.exe under the bin folder.

In other words run:

<MONGO_HOME>\bin\mongod.exe

To make sure that the main MongoDB database process is running, run mongo.exe (Mongo Shell) which also resides under the same folder. If it connects successfully and greets you with the shell awaiting your commands, then your database is up and running. Go back and restart compound server to see if it helped. If it did not, check your database connection settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top