0
votes

I am unable to access mongo shell in Ubuntu 16.04, but am able to run

sudo mongod

and its working , but when i try to run

mongo or sudo mongo

the following error raises

MongoDB shell version v3.4.6

connecting to: mongodb://127.0.0.1:27017 2017-07-26T14:33:50.413+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused 2017-07-26T14:33:50.414+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6 exception: connect failed

1
How about sudo service mongod start.Burdy
@Burdy I checked with sudo service mongod start but the when i checked the status using sudo service mongod status I got this ● mongod.service - High-performance, schema-free document-oriented database Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2017-07-26 14:43:16 UTC; 6s ago Docs: docs.mongodb.org/manual Process: 2086 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=100) Main PID: 2086 (code=exited, status=100)Sreekanth P M

1 Answers

0
votes

Print the last line of cat /var/log/mongodb/mongod.log and the content of /etc/mongod.conf.

Ensure that in /etc/mongod.conf the dbPath exists, the port is correctly bind to 27017, host is 127.0.0.1

In addition try to remove the mongod socket file /tmp/mongodb-27017.sock