micobg micobg - 1 month ago 10x
Linux Question

Mongo: couldn't connect to server at src/mongo/shell/mongo.js:145

When I try to run mongo in shell in ubuntu or open rockmongo I see this error:

couldn't connect to server at src/mongo/shell/mongo.js:145

What's the reason? I tried to reinstall mongo but this didn't help. When I type
sudo apt-get purge mongodb-10gen
returned error is

E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried this:

  • first remove line about mongo in /etc/apt/sources.list

  • run this commands:

    sudo dpkg pr mongofb-10gen

    sudo apt-get -f install

    sudo apt-get upadte

    sudo apt-get upgrade

  • then
    sudo apt-get purge mongodb-10gen
    is successful

  • at the end:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

  • add deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
    in /etc/apt/sources.list

    sudo apt-get update

    sudo apt-get install mongodb-10gen

Then when I try to start mongo i saw the same error. :o


I assume that you followed the steps, outlined here.

Most probably you have a problem with mongo lock (or at least I had it once while installing on ubuntu). I solved it with the following commands:

sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart

P.S. I by myself recently experienced this problem when I was updating my amazon ec2 instance. I have not properly shut down mongo before doing this and this resulted in a problem with mongo lock.