Mongodb 3.4 - fail to start mongodb - mongodb

How can I start mongodb. The child process fail.
-bash-4.1$ mongod --config /mongodb/etc/mongod-ctr.conf
about to fork child process, waiting until server is ready for connections.
forked process: 22965
ERROR: child process failed, exited with error number 48
-bash-4.1$ mongo
MongoDB shell version v3.4.17
connecting to: mongodb://127.0.0.1:27017
2018-11-27T13:52:13.826-0500 W NETWORK [thread1] Failed to
connect to 127.0.0.1:27017, in(checking socket for error after
poll), reason: Connection refused

According to the MongoDB error code manual, and your error status, there seems to be another process either running on port 27017, or you just don't have the right permissions.
You can use the command lsof -i -P -n to see a list of all applications, and the ports they are using.

Related

Can't login to Wekan DB CentOS console

I have recently installed Wekan on a CentOS (CentOS Linux release 7.6.1810) server and it works well. However I need to login to the MongoDB. I have followed the installation guide of MongoDB and set a password for 'admin' user. But when When the "mongo -u admin -p" command is entered it prompts for password and I get the following error. However I have another issue not starting "mongod", but it is enabled.
connecting to: test
2020-06-12T01:20:23.618-0400 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2020-06-12T01:20:23.618-0400 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
I created this user in mongo which does not seem to work when trying to login to the DB.
$ mongo
db.createUser(
{
user: "admin",
pwd: "abcd1234",
roles: [ { role: "root", db: "admin" } ]
}
)
Firstly I installed the latest version of mongodb and then I downgraded to to 3.2 which works with wekan. However Wekan still works fine without any issue.
This is the error I get when starting the mongod.
$ systemctl start mongod
Job for mongod.service failed because the control process exited with error code.
See "systemctl status mongod.service" and "journalctl -xe" for details.
$ systemctl enable mongod
mongod.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mongod on
The port mongod uses is 27019 which I found from the following command.
$ ss -nutlp
tcp LISTEN 0 128 127.0.0.1:27019 *:* users:(("mongod",pid=11578,fd=6))
What am I doing wrong here?
In the output of the mongo shell connection failure:
Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
This tells you that it is attempting to connect to port 27017 on localhost, and that the operating system actively refused the connection because nothing is listening on that port.
The ss output shows that mongod is listening on port 27019.
Try adding --port 27019 to your mongo command line.

Connection error while installing mongodb on Fedora 28

I have been trying to install Mongodb but it keeps failing midway. When the download is complete, installation fails with a connection error:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-08-17T12:26:33.340+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:26:33.340+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
What I've tried:
1. Changing the port:
mongo --port 4332
but it doesn't connect still:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:4332/
2018-08-17T12:32:55.743+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:4332, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:32:55.743+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:4332, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Reinstalling the DB shows up as complete but I still can't start it. Check out the screenshot
Checking for any config files in /etc/mongo* or /var/lib/: there is none.
Note: There's no mongod service available too.
the installation seem to have worked, but the mongod was not started.
MongoDB need two element :
the "mongo" shell utility, who is used to connect to the database direcly
the "mongod" service, who is the true database programs.
to start the mongod, simply use a cmd and use the "mongod" command. this command may fail if :
the port is already used (default is 27017)
the dbpath directory was not created (default is /data/db)
Fedora repository do not install both at the same time.
the shell is in the repository under the "mongodb" name
the server is under the name "mongodb-server"
so to install both, you need to do
dnf install mongodb mongodb-server
and you can then start the mongod service with
sudo service mongod start
more information

Getting error with mongo commend after install mongodb version 3.6.3

I have facing issues while running mongo commend after successful installation of mongoDB version 3.6.3.
I have run mongo commend and got the following error
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-03-14T18:57:02.928+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-03-14T18:57:02.929+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Run into the same problem, my error was that I was this command:
sudo mongo service mongod start
Instead of this:
sudo service mongod start
Make sure you run the second one, hopefully that is your error source as well.

Could not connect to mongodb. errno:111 Connection refused

I am using mongodb on ubuntu-16.04 but mongodb give server connection error:
MongoDB shell version: 3.2.9 connecting to: test
2016-09-23T12:01:10.258+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-09-23T12:01:10.286+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect#src/mongo/shell/mongo.js:229:14 #(connect):1:6 exception: connect failed
What can I do?
looks like your mongod process is not running on port 27017. Make sure your mongod process is running maybe verify with linux command.
If you start mongod process and even then it's failing to connect with mongo command, it means it's failing to intialize, check out designated mongo log file for the reason

Shutdown mongos for upgrade

I am upgrading a mongo sharded cluster, and am in the first step of replacing the mongos process. Can I just kill this process or is there a safer way to shut it down before replacing it?
It is the answer. But may be you misunderstood. You cannot shutdown mongos from command line, but you have to logon to the shell. Here is the result I am trying on my own:
$ mongo --port 27077 (please replace with your own port on mongos instance)
**mongos**> db.shutdownServer({timeoutSecs:30})
shutdown command only works with the admin database; try 'use admin'
mongos> use admin
switched to db admin
mongos> db.shutdownServer({timeoutSecs:30})
2015-02-27T12:53:54.408+0800 DBClientCursor::init call() failed
**server should be down...**
2015-02-27T12:53:54.410+0800 trying reconnect to 127.0.0.1:27077 (127.0.0.1) failed
2015-02-27T12:53:54.410+0800 warning: Failed to connect to 127.0.0.1:27077, reason: errno:111 Connection refused
2015-02-27T12:53:54.410+0800 reconnect 127.0.0.1:27077 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27077 (127.0.0.1), connection attempt failed
2015-02-27T12:53:54.413+0800 trying reconnect to 127.0.0.1:27077 (127.0.0.1) failed
2015-02-27T12:53:54.413+0800 warning: Failed to connect to 127.0.0.1:27077, reason: errno:111 Connection refused
2015-02-27T12:53:54.413+0800 reconnect 127.0.0.1:27077 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27077 (127.0.0.1), connection attempt failed
>
Try to run "top" or "htop" to display all processes running on your computer. You shall see the "mongos" process has gone. Read the log file. Here is the last two lines of my log:
2015-02-27T12:53:54.406+0800 [conn1] terminating, shutdown command received
2015-02-27T12:53:54.406+0800 [conn1] dbexit: shutdown called rc:0 shutdown called
And here is the link of my testing script:
https://github.com/babycaseny/QuickStart/blob/master/StartShard.sh
Note that you have to replace the "localhost" in the mongod/mongos command with the hostname of your computer, or you will not be able to config your shards.
See also this one:
https://groups.google.com/forum/#!topic/mongodb-user/TQLlRI6HG1M
In case you need a command line to do the work, here is one:
mongo admin --port portnumber --eval "db.shutdownServer()"
Notice that you have to run the command in localhost.