Free Code Camp Implement the Serialization of a Passport User - 'Error: Unable to Connect to Database'

Here’s the problem:

My Database is not connecting in my application (for either Repl.it or Glitch)


Here is what I have thus far:

Sample.env:
image

Server.js, Part 1:

Server.js, Part 2:

Database, Part 1:

Database, Part 2:

File Structure:


Here’s the Output:


What I’ve Done:

I’ve searched on Google, consulted with a colleague, and scoured through this forum along with Github. But nothing has gotten me close to solving my problem of connecting my database to my application. Any ideas on what I’m missing?

Can you post a link to your repl.it or Glitch version, so we can test it and see the full code?

I’d be happy to. If I may ask, will my environment variables be shown? It’d my first time posting a link to my repl.it.

Additionally, I don’t think my .env variables are carrying over. Case in point, I console logged the variable SESSION_SECRET. And it doesn’t contain data.

Hey @RandellDawson , I deleted the sample.env file and replaced it with .env. This allowed my data to carry over:

However, I didn’t have my cluster available for open access. Which I went ahead and rectified:

Turns out that those two things solved my problem:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.