title: Cannot connect to MongoDB instance on AWS EC2 instance
body: <p>I have created a MongoDB instance on an AWS EC2 Ubuntu instance.</p>
  
  <p>MongoDB is running and when I <code>ssh</code> into the machine and run the MongoDB <code>mongod</code> console, I am able to create databases, so I am confident it is running successfully.</p>
  
  <p>However, I am not able to gain access to the database from my local machine in a browser.</p>
  
  <p>I have changed the <code>bindIp</code> in <code>/etc/mongod.conf</code> to <code>0.0.0.0</code>, and I have opened port 27017 by executing <code>sudo ufw allow 27017</code> but my browser still times out trying to connect.</p>
  
  <p>When I try to configure the instance using <code>mongod --config /etc/mongod.conf</code>, I get the error:</p>
  
  <pre><code>CONTROL  [main] Failed global initialization: FileNotOpen: Failed to open "/var/log/mongodb/mongod.log"
  </code></pre>
  
  <p>This file exists! The relevant portion of the config file looks like this:</p>
  
  <pre><code>systemLog:
    destination: file
    logAppend: true
    path: /var/log/mongodb/mongod.log
  </code></pre>
  
  <p>I have read that you have to enable the REST interface by specifying <code>--rest</code>, but I don't know how to do this since I am starting the database service with the <code>sudo service mongod start</code> command.</p>
  
  <p>My AWS security settings looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Fq4jt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fq4jt.png" alt="enter image description here"></a></p>
  
  <p>What am I missing?</p>