MongoDB, Mongoose Create and Save A Record is timing out

I am stuck on the Create and Save A Record challenge of the Mongo+Mongoose module in the APIs and Microservices certification. I thought it might be because I was running my solution on Heroku, but when I reproduced my code in Glitch I’m still getting the timeout. My code passes the first two challenges of the module, so I know my issue is in the creation/saving process, and by logging I can see that the Person document is being created properly. I compared my solution to the official solution and they are essentially identical, so i don’t understand what I’m doing wrong.

Here is a link to the Glitch project.

Here is my package.json:

{
 "name": "fcc-mongo-mongoose-challenges",
 "version": "0.0.1",
 "description": "A boilerplate project",
 "main": "server.js",
 "scripts": {
   "start": "node server.js"
 },
 "dependencies": {
   "express": "^4.17.1",
   "body-parser": "^1.19.0",
   "mongodb": "^3.5.5",
   "mongoose": "^5.9.5"
 },
 "engines": {
   "node": "12.0.0"
 },
 "repository": {
   "type": "git",
   "url": "https://hyperdev.com/#!/project/welcome-project"
 },
 "keywords": [
   "node",
   "hyperdev",
   "express"
 ],
 "license": "MIT"
}

and here is the code so far in myApp.js:

const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true }); 

var Schema = mongoose.Schema;
var personSchema = new Schema({
  name: { type: String, required: true},
  age: Number,
  favoriteFoods: [String]
});
var Person = mongoose.model('Person', personSchema);

var createAndSavePerson = function(done) {
  var johnDoe = new Person({
    name: "John Doe", 
    age: 27, 
    favoriteFoods: ["pizza", "breakfast"]
  });
  johnDoe.save(function(err, data) {
    if (err) return done(err);
    done(null, data);
  });
};

browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36.

I solved my own problem: I had copied the wrong URI for MongoDB Atlas. I was using the URI for connection through a shell, which will prompt the user for their password; what I needed was the URI for a connection through an application, which actually has a spot to put a password, and to replace<password> with my own password.

This got it to work for Glitch, by putting the correct URI in the .env file. For Heroku, the CLI command heroku set:MONGO_URI='<uri>' doesn’t seem to like receiving the URI in quotes, and what I had to do was configure the environment variable through the Dashboard, and input the URI there without surrounding quotes.