Issues starting mongodb instance via mongodb shell - mongodb

I entered sudo service mongod start in my MongoDB shell (Ubuntu)
got the following error:
[js] uncaught exception: SyntaxError: unexpected token: identifier :
#(shell):1:5
Any advice?

Related

MongoDB shell not running commands

I installed the mongo shell and when I try to run a command (even mongo --version) it returns this error:
'2020-04-29T17:39:25.320+0300 E QUERY [js] uncaught exception: SyntaxError: unexpected token: identifier :
#(shell):1:5'.
What am I doing wrong?

Error while connecting Mongo to localhost

I have Robo 3T-1.3 installed on my ubuntu 16.4 LTS.
It is showing me the following error:
`Cannot connect to the MongoDB at localhost:27017.
Error:
Network is unreachable. Reason: couldn't connect to server localhost:27017, connection attempt failed: SocketException: Error connecting to localhost:27017 (127.0.0.1:27017) :: caused by :: Connection refused`
How to solve it?
Firstly check your mongo status via this command.
sudo systemctl status mongod
OR
You can follow this link.
https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04

While o i am trying to start i am getting the below error

While o i am trying to start i am getting the below error
#(connect):1:6
exception: connect failed
C:\MongoDB\Server\4.0\bin>mongodb
'mongodb' is not recognized as an internal or external command,
operable program or batch file.
C:\MongoDB\Server\4.0\bin>mongo start
MongoDB shell version v4.0.6
connecting to: mongodb://127.0.0.1:27017/start?gssapiServiceName=mongodb
2019-03-06T15:44:04.853+0530 E QUERY [js] Error: couldn't connect to server 1
27.0.0.1:27017, connection attempt failed: SocketException: Error connecting to
127.0.0.1:27017 :: caused by :: No connection could be made because the target m
achine actively refused it. :
connect#src/mongo/shell/mongo.js:343:13
#(connect):1:6
exception: connect failed
Your using mongodb as command to start MongoDB but it should be mongod
To start MongoDB Server, run mongod.exe. Using below command,
mongod --dbpath="<DATABASE DIRECTORY>"
Then you can connect with MongoDB, Using command mongo
Default path MongoDB on Windows at C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe

Mongo failed to start

I am running a mean app, but when I go to run 'mongo', I get the following error:
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-07-25T02:15:24.329-0500 E QUERY [js] Error: couldn't connect to
server 127.0.0.1:27017, connection attempt failed: SocketException: Error
connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
I am sure I am missing something simple here.
mongo is the Mongo shell. It connects to the Mongo daemon, mongod, which isn't running - hence the error.
At the command-line: sudo mongod
Enter your password, and the daemon should start. Now, when you run mongo it should start up ok.

Error during mongo startup

When I type mongo on command prompt than output like
~$ mongo
MongoDB shell version: 2.2.3
connecting to: test
But when I type mongo 127.0.0.1:28017/stu1
output :-
MongoDB shell version: 2.2.3
connecting to: 127.0.0.1:28017/stu1
Mon Mar 10 16:56:01 DBClientCursor::init call() failed
Mon Mar 10 16:56:01 Error: Error during mongo startup. :: caused by :: 10276
DBClientBase::findN: transport error: 127.0.0.1:28017 ns: admin.$cmd query: { whatsmyuri: 1 } src/mongo/shell/mongo.js:93
exception: connect failed
OS :- ubuntu 12.04
So please help me to solve this error.
28017 is the default port for the HTTP admin interface, so if your config is allowing HTTP, you should use a web browser to access it http://127.0.0.1:28017/
You're trying to use mongo shell to access HTTP service.
To have access to the database using HTTP protocol then use ~$ mongod --rest to start the db. Now call http://127.0.0.1:28017/stu1/coll_name in the web browser which list all the documents in your collection.