MongoDB Error: couldn't connect to server in linux - linux

When I type 'mongo' in terminal to run the mongo server. it doesn't run. It shows me the eroor : couldn't connect to server. exception: connection failed.
Then I tried to restart mongodb server by
$ sudo systemctl start mongod
$ sudo systemctl status mongod
When I run the status command, I see it is showing
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor prese
Active: failed (Result: exit-code)
N.B - I am running linux mint 20.1. And I have read all the answer and tried. But nothing worked for me.
Oh, I followed this guide to install, uninstall and reinstalling MongoDB. But still it is not working for me.

Related

Error while creating project with strapi and mongo

Previously i installed mongo using guide from strapi documentation. If i wrote command
service mongod status
I get log about working db:
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-10-08 11:38:50 EEST; 41min ago
Docs: https://docs.mongodb.org/manual
Main PID: 972 (mongod)
CGroup: /system.slice/mongod.service
└─972 /usr/bin/mongod --config /etc/mongod.conf
But when i try to create project using command and choosed mongo as database
npx create-strapi-app my-project
i get error
⛔️ Connection test failed: Command failed: yarnpkg --cwd
/tmp/strapi0b12da72e284 add strapi-connector-mongoose#3.2.1 error An
unexpected error occurred: "https/strapi-connector-mongoose: Invalid
URI "https/strapi-connector-mongoose"".
and as result project doesn't create
Solved this issue by changing registry of npm config. Command for fix:
npm config set registry https://registry.npmjs.org/

Failed to stop mongodb.service while installing MongoDB on Ubuntu

While installing Mongodb I am facing error like
Failed to stop mongod.service: Unit mongod.service not loaded.
I tried to stop this service using-
~$ sudo systemctl stop mongodb
but it givs same error, I also check the status for mongodb using command
sudo systemctl status mongodb
this will result following response
● mongodb.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
I can install mongodb only after mongod.service get stoped, please guide how to stop service.
You need to create the mongod.service first. Then enable and stop
https://programmersought.com/article/28701054205/#:~:text=%2Flib%2Fsystemd%2Fsystem%2Fmongod.service
Execute this command in terminal
sudo systemctl enable mongod
After that check the status of service using
sudo service mongodb status
then you will be able to stop the service.

DataStax opscenterd won't start on Ubuntu 15.04 x64

Issue:
sudo service opscenterd start
Failed to start opscenterd.service: Unit opscenterd.service failed to load: No such file or directory.
(ERROR)-(Exit Code 6)-(Unknown error code)
sudo service opscenterd status
opscenterd.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Config
[webserver]
port = 8888
interface = 0.0.0.0
I tried another port and ip (localhost)
Cassandra installed and running (dsc21, cassandra 2.1.10)
no log files been generated in /var/log/opscenter/
opscenter installed via apt-get (5.2)
Please help me to resolve this issue
I have the same issues as you, seems like OpsCenter could not run as service on Ubuntu 15, I went running it as background process and it works,
try:
$ sudo your_opscenter_install_path/bin/opscenter
hope helpping

MongoDB connection failed, should I restart server or restart MongoDB

my computer is Ubuntu 14.04 LTS and I am connecting to a server to run codes. I also use the mongo on this server. However, it suddenly closed and when I tried to connect to the mongo shell, it shows:
MongoDB shell version: 2.6.9
connecting to: test
2015-05-02T16:37:34.643+0200 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-05-02T16:37:34.643+0200 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
So should I restart mongo or should I restart the server? I use ps command to see all progresses on the server under my account, which is:
PID TTY TIME CMD
107018 pts/16 00:00:00 ps
233611 pts/16 00:00:00 bash
Does that mean that I cannot restart the server?
It seems mongodb suddenly shut down.
use sudo service mongodb restartto restart mongodb.
if it does not work and it is a test machine/personal computer ,
restart the machine is a good choice.
in addition,ps only shows your own process,sudo ps shows all process.

MongoDB service not running in Fedora

Just installed a clean version of mongodb on Fedora 17 64-bit, but the Mongo service wont run.
I followed these instructions during installation
Running
service mongod start
results in
Starting mongod (via systemctl): Job failed. See system journal and 'systemctl status' for details. [FAILED]
So I ran
systemctl status mongod.service
which gives me
mongod.service - SYSV: Mongo is a scalable, document-oriented database.
Loaded: loaded (/etc/rc.d/init.d/mongod)
Active: failed (Result: exit-code) since Mon, 18 Jun 2012 13:15:56 +0200; 58s ago
Process: 13584 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)
CGroup: name=systemd:/system/mongod.service
Mongo logs in /var/log/mongo/mongod.log is empty
Thanks
How to install mongodb and mongodb-server on fedora linux (verified on f16 & f17). All commands are intended to be run in a su session.
1) make sure you have no mongodb installation lying around
# yum erase mongodb
# yum erase mongo-10gen (if it is installed)
2) install from fedora yum repository
# yum --disablerepo=* --enablerepo=fedora,updates install mongodb mongodb-server
3) start mongod (mongodb daemon)
# systemctl start mongod.service
4) verify mongod is running
# systemctl status mongod.service
# tail /var/log/mongodb/mongodb.log
# nmap -p27017 localhost
or running client
# mongo
MongoDB shell version: 2.0.2
connecting to: test
> db.test.save( { a: 1 } )
> db.test.find()
{ "_id" : ObjectId("4fdf28f09d16204d66082fa3"), "a" : 1 }
5) customize configuration
# vim /etc/mongodb.conf
# systemctl restart mongod.service
6) make mongodb service automatically start at boot
# systemctl enable mongod.service
Update for Fedora 18
When started for the first time by systemd on a slow or loaded machine, mongod service might timeout before finishing its initialization, with systemd flagging the service as failed.
Symptoms:
# journalctl -xn
-- Unit mongod.service has begun starting up.
10:38:43 local mongod[24558]: forked process: 24560
10:38:43 local mongod[24558]: all output going to: /var/log/mongodb/mongodb.log
10:40:13 local systemd[1]: mongod.service operation timed out. Terminating.
10:40:13 local systemd[1]: Failed to start High-performance, schema-free document-oriented database.
-- Subject: Unit mongod.service has failed
Very easy cure, restart the service:
# systemctl restart mongod.service
this should finish the initialization successfully and leave the daemon in running state.
I just had the same issue and in my case it was caused by installing mongodb following instructions of some websites using non-official repo. If you have the same issue and the answer above are not solving your problem, try uninstalling "mongodb-org" package and reinstalling it following the instructions of the official documentation : https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Remainder to uninstall package in fedora:
sudo dnf remove <package-name>

Resources