Chen Zissu
Chen Zissu

Reputation: 73

mongo: failed to connect to server [localhost:27017]

happened to someone?

what can I do to solve this problem? I'm on windows so I can't run sudo mongo I tried to do "runas" in windows instead of linux "sudo" but it didn;t help me out. I was looking for a fle called monogod.lock to remove it but didn't find something like that...I tried mongo repair but it also didn't help me...help someone?

btw...I tried to start mongo.exe from it's directory in another CMD but it failed also: enter image description here

Upvotes: 1

Views: 5010

Answers (3)

Raul Dgz Casaos
Raul Dgz Casaos

Reputation: 1

In linux

1.- In the terminal

$ sudo systemctl start mongodb

$ mongo

Upvotes: 0

Chen Zissu
Chen Zissu

Reputation: 73

oh guys I finally got that! when you run mongod.exe on windows you should also give it the path of the directory if not it won't work! if somehow you'll have a mongod.lock on your directory you should delete this file than write on CMD mongod.exe repair and start running it again! thanks to all =]

Upvotes: 0

RLD
RLD

Reputation: 2005

Seems you have not started the Mongo DB Server. Do the followings.

  1. In Windows, start Command Prompt.
  2. Run mongod.exe to start Mongo DB Server.(This will work only if your environment variable PATH contains the bin directory of your Mongo DB installation)
  3. Open another Command Prompt and start client by running mongo.exe.

Check this link which might help you.

MongoError: failed to connect to server [localhost:27017] on first connect

Upvotes: 1

Related Questions