DevOps | Cloud | Analytics | Open Source | Programming





How To Fix Permission Error while Starting MongoDB Server ?



This Post explains - How To Fix Permission Error while Starting MongoDB Server.

Issue:


If you had set-up MongoDB as per the official documentation, sometimes we face the below error -


> _\[main\] error opening file: /etc/key: **Permission denied**_
> 
 

Reason:


This mostly mostly happens due to a piece of information which we sometimes miss or probably forget about. And that information is -

  • Typically MongoDB is installed with username "mongod".
  • But my mistake sometimes we use root user to start the server. Which throws the above error

Fix:


  • Hence we need to change the ownership to "mongod" by using following command.

sudo chown mongod:mongod /etc/key"

  • If you do that and Restart the server , it should work !
  I hope this was helpful   Additional Read :