mongodb not working “ERROR: dbpath does not exist”

I’m getting the following error when I try to run “mongod” in the terminal. I’ve tried uninstalling, reinstalling, and restarting the machine. Any suggestions on how to get it working would be amazing.


dbpath (/data/db) does not exist.
 Create this directory or give existing directory in --dbpath.

Side note: Node also stopped working on my machine around the same time that I got this error.

        throw er; // Unhandled 'error' event
Error: failed to connect to [localhost:27017]

Any help would be much appreciated!

share|improve this question
Did you follow the directions in the error message? –  JohnnyHK Jul 6 at 18:47

2 Answers

This should work to ensure that the directory is set up in the right place so that Mongo can find it:

sudo mkdir -p /data/db/

sudo chown `id -u` /data/db

share|improve this answer

You need to create the directory on root /data/db or set any other path with the following command :

mongod --dbpath /srv/mongodb/

See the example link


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s