1

I wrote these lines in My Application start event:

    var mongo = new Mongo();
    mongo.Connect();
    var blog = mongo.GetDatabase("Blog");
    mongo.Disconnect();

but on this line: mongo.Connect(); it gave me this error:

No connection could be made because the target machine actively refused it 127.0.0.1:27017

I am a beginner using Mongodb and i am just try to make sample code to see it's power.
So i have no idea how to solve this problem.

I am using VS2008 with MongoDB.Driver on Windows7.

UPDATE

I got also that the same problem is happening while trying this tutorial: http://www.mongodb.org/display/DOCS/Tutorial#Tutorial-GettingADatabaseConnection using the shell.

1
  • yes, in the tutorial i wrote : use mydb and it worked, but 'Inserting Data into A Collection' gave me the error that it can't connect to 127.0.0.1:27017 Commented Apr 7, 2010 at 23:17

3 Answers 3

1

i found the problem, the problem that mongodb is pointing to the default database directory c:\data\db

now i will try to get how to change this directory to another one.

http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, how did you find out? It is always helpful to know how to debug better.
1

When this problem occurs, you must delete the mongod.lock file. MongoDB then immediately creates a new lock, and the service becomes available again.

BTW, in order to work with MongoDB more easily, check out MongoVUE at http://www.mongovue.com.

Comments

1

For this problem what you can do is just check your dbpath in mongod.cfg file in your mongo folder.

It should be the exact path of your data folder like for example dbpath=e:\data\db.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.