Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
Mongodb connection error whenever rebooting server

I am using aws and installed ubuntu server on aws ec2. I installed mongodb on it. When installing mongodb, it is working well. But If i reboot server and try to connect mongod in termina. I am getting the following error.

MongoDB shell version v4.4.0 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 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:362:17 @(connect):2:6 exception: connect failed exiting with code 1

So whenever reboot server, i have to execute the following command and then mongo is working again. sudo systemctl stop mongod sudo rm /var/lib/mongodb/mongod.lock sudo mongod --repair --dbpath /var/lib/mongodb sudo mongod --fork --logpath /var/lib/mongodb/mongodb.log --dbpath /var/lib/mongodb sudo systemctl start mongod

I think whenever reboot server, executing above command does not make sense. If anyone have experienced, please help me. Thanks.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

After you setup the mongodb you usually would enable it, so that it starts after each reboot:

sudo systemctl enable mongod
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!