Buckyx55
Buckyx55

Reputation: 524

Heroku Not Connecting to Mongo Atlas DB?

My app won't properly deploy or connect to my Mongo Atlas DB on Heroku. It keeps crashing. The heroku URL just says to do the logs, so here are the command line logs: Command line logs

Here is what my server.js file looks like: server.js file

Here is what my config/keys looks like: config/keys file

Here is what my keys_prod.js file looks like: keys_prod.js file

Here is what my keys_dev.js file looks like (redacted username and password), but this is what I have for my config vars in the heroku backend as well enter image description here

Also took this screenshot, not sure if it matters though: enter image description here

Upvotes: 2

Views: 3641

Answers (2)

Buckyx55
Buckyx55

Reputation: 524

I didn't set the Heroku config vars correctly. I had set it to mongoURI like it was in the prod.keys JS folder instead of being MONGO_URI like I had declared it. In addition, I had to whitelist all of the ip's in Heroku's settings.

Upvotes: 1

vamshi krishna
vamshi krishna

Reputation: 2937

In deployment platforms like heroku, its hard to configure .env . i solved this in my project by using a npm package dotenv. Whatever file need process.env init,use this package

common require.js way :

require('dotenv').config()

its also got some cool options to manage env

here is the link

Upvotes: 0

Related Questions