title: How to set Python EVE REST API serving settings for the database on MongoDB Atlas
body: <h1>Problem Summary</h1>
  <p>I'm trying to setup a python eve REST API server with mongodb at localhost 5000 (<a href="http://127.0.0.1:5000/" rel="nofollow noreferrer">http://127.0.0.1:5000/</a>). In the beginning, my mongodb was hosted at localhost 27017, and the API connection worked perfectly. But I want to change the database to a cloud server, so I dumped my db to MongoDB Atlas and tried to revise the MONGO_HOST and add the user credentials in the <em>settings.py</em> file. But it didn't work. Here's the code I've tried to revise.</p>
  <h1>Before change</h1>
  <p><em>settings.py</em></p>
  <pre class="lang-py prettyprint-override"><code>MONGO_HOST = 'localhost'
  MONGO_PORT = 27017
  MONGO_DBNAME = 'mydb'
  ...
  SERVER_NAME = '127.0.0.1:5000'
  URL_PREFIX = 'api'
  </code></pre>
  <h1>After change</h1>
  <p><em>settings.py</em></p>
  <pre class="lang-py prettyprint-override"><code>MONGO_HOST = '&lt;clustername&gt;-mz123.gcp.mongodb.net'
  MONGO_USERNAME = 'user'
  MONGO_PASSWORD = 'user'
  MONGO_DBNAME = 'mydb'
  ...
  SERVER_NAME = '127.0.0.1:5000'
  URL_PREFIX = 'api'
  
  </code></pre>
  <p>I've also tried to follow the instruction from <a href="http://api.mongodb.com/python/current/atlas.html" rel="nofollow noreferrer">official</a> to access the mongoDB Atlas with pymongo and it worked successfully as below. So I think the problem may exactly be how to set the eve <em>settings.py</em> file for connecting to MongoDB Atlas in the correct way.</p>
  <pre class="lang-py prettyprint-override"><code>from pymongo import MongoClient
  client = MongoClient(&quot;mongodb+srv://user:password@&lt;clustername&gt;-mz123.gcp.mongodb.net/test?retryWrites=true&amp;w=majority&quot;)
  db = client['db']
  col = db['collection']
  </code></pre>
  <h1>My questions and thoughts</h1>
  <ol>
  <li><p>Is there any setting parameter I just missed? I'm not sure if the name of MONGO_HOST is wrong, but I just got it from the instruction on Atlas website.  Or do I need to change the setting to the form like MONGO_URI instead? But I've tried and failed, too. LOL</p>
  </li>
  <li><p>Does the eve REST API serve only for localhost DB (27017) when serving at localhost 5000?</p>
  </li>
  <li><p>Any suggestions? Thanks!</p>
  </li>
  </ol>