2
votes

I haven't worked on my PC for few days.

Suddenly all the calls to mongo via mongoose hangs up, the callbacks are not called.

I checked that my call to .connect works, and that the connection state is 1 (connected).

I also made sure mongo service is running on localhost and the appropriate port 27017, and I can use the mongo console and query the db manually.

I also scanned the Internet for solutions but all I found was 'check that you're actually connected', and I verified that already.

Mongoose version 2.15.0, mongo version 2.4.9 and node js version is 4.4.2.

1
Are you using promises or regular callbacks?robertklep
I would recommend to create new file in new folder then "npm install mongoose", in the file require mongoose, copy/paste one of your existing schema/model definition and try SomeModel.find({},function(){...});Molda
OK I realized that when the schema sits in the node modules of the module then it works. What I've done before is moving it one level up in the hierarchy to the node modules folder of all my other services (since I'd like to share schemas with all my micro services). In the last manner it does not work. But when I move it one level down inside the module itself then the call is working...Jjang
But it's still not good because I'd like it to stay in the global node modules hierarchy so it will be available to all the micro services...Jjang

1 Answers

10
votes

I fixed it.

Problem was duplicate references to the mongoose module.

I had a mongoose reference locally (which was connected), but my schema was present higher in the node_modules hierarchy, and it have used another mongoose instance which had no connection.

Once I removed the duplicate mongoose modules (npm uninstall mongoose one of them) it worked.