Mflix NOT loading: Is my connectionStrings Wrong?

Hi @yousaid,

Could you try the following steps on your mac for me please?

  1. make sure that you have mongo version 4+ installed
  2. cd into your mflix directory
  3. run the following command mongo mongodb+srv://m220student:m220password@mflix-ydaxv.mongodb.net.

I got this srv string from your original post at the top of this thread. I am not able to connect, so there seems to be an issue with your atlas cluster. If are unable to connect as well, please copy the connection string that you get when hitting Connect -> Connect your Application in the page that you added in your previous message as a screenshot.

Once I get the connection string from the Connect your Application window in Atlas, we’ll be able to work out the next step.

Looking forward to hearing from you.

Hello,
Thanks for reaching out. Yes, something is definitely wrong with the Cluster.
Here is what I get when I follow the instructions above. It FAILS with this error below:
adminadminsMBP2:documents adminadmin$ cd mflix

adminadminsMBP2:mflix adminadmin$ mongo mongodb+srv://m220student:m220password@mflix-ydaxv.mongodb.net.

MongoDB shell version v3.4.6

connecting to: mongodb://mongodb+srv://m220student:m220password@mflix-ydaxv.mongodb.net.

2019-03-18T20:17:42.889-0400 W NETWORK [thread1] Failed to connect to 198.105.244.130:27017 after 5000ms milliseconds, giving up.

2019-03-18T20:17:42.890-0400 E QUERY [thread1] Error: couldn’t connect to server mflix-ydaxv.mongodb.net.:27017, connection attempt failed :

connect@src/mongo/shell/mongo.js:237:13

@(connect):1:6

exception: connect failed

adminadminsMBP2:mflix adminadmin$

HERE is the ConnectionString from Connect Your Application:

mongodb+srv://m220student:@mflix-onr8e.mongodb.net/test?retryWrites=true

Thanks much

Are you still keeping 2 clusters? If the previous project name is m220, that is ok. I see if we successfully restore the whole data onto the cluster, it will occupy about 300MB, just a bit to reach the limit 500MB the free M0 providing us. If you have an big data not relevant to this course, you have to back up for available space for mflix project.

Did you give permission to your IP address to access the cluster?

Hi @yousaid,

It looks like you are trying to connect to the wrong cluster. The connection string that you provided at the end of your response works, so let’s try to use that to import your data.

I’m assuming that you added a whitelisted I.P. If not, before proceeding please follow step 5 in the Creating a free tier cluster called “mflix” in the README lecture in Chapter 1.

Try these steps and let me know what you get:

  1. cd mflix-js
  2. mongorestore --drop --gzip --uri "mongodb+srv://m220student:m220password@mflix-onr8e.mongodb.net" data

Thanks again, BUT, sadly, that did not work. Here is what I get.
adminadmins-MacBook-Pro-2:mflix adminadmin$ mongo mongodb+srv://m220student:m220password@mflix-onr8e.mongodb.net.

MongoDB shell version v3.4.6

connecting to: mongodb://mongodb+srv://m220student:m220password@mflix-onr8e.mongodb.net.

2019-03-19T16:34:28.707-0400 I NETWORK [thread1] getaddrinfo(“mflix-onr8e.mongodb.net.”) failed: nodename nor servname provided, or not known

2019-03-19T16:34:28.707-0400 E QUERY [thread1] Error: couldn’t initialize connection to host mflix-onr8e.mongodb.net., address is invalid :

connect@src/mongo/shell/mongo.js:237:13

@(connect):1:6

exception: connect failed

adminadmins-MacBook-Pro-2:mflix adminadmin$

Here is a listing of my mflix directory
adminadmins-MacBook-Pro-2:mflix adminadmin$ ls
README.rst dotenv_win package-lock.json
build index.js package.json
data jest.config.js src
dotenv_unix node_modules test
adminadmins-MacBook-Pro-2:mflix adminadmin$

Here is MongoDB on my Local box:
Last login: Mon Mar 18 20:17:03 on ttys002
adminadmins-MacBook-Pro-2:~ adminadmin$ mongo
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.6
Server has startup warnings:
2019-03-18T20:10:11.480-0400 I CONTROL [initandlisten]
2019-03-18T20:10:11.480-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-03-18T20:10:11.480-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-03-18T20:10:11.480-0400 I CONTROL [initandlisten]
2019-03-18T20:10:11.480-0400 I CONTROL [initandlisten]
2019-03-18T20:10:11.480-0400 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

HERE is what I did:
Step 1: Start Mongodb from a Terminal, by typing: mongo
Mongodb starts ok as noted above.
Step 2: Open a NEW Terminal
Step 3: cd to my myflix directory.
Step 4: Run the command you gave
I get the error I posted above.
Thanks again

Yea, I am keeping both clusters so I can continue to learn MongoDB with that one that works. But the data size is very small though and should not be an issue. The data size is below 300 last time I checked.

Something is wrong in your cut-n-paste.

You show following command:

Yet mongo tells:

For some reason mongodb is repeated as mongodb://mongodb+srv:.

May be the mac shell interprets the + sign in some way. I would try to put the connection string inside single quote.

2 Likes

Interesting, ok. I will try to Test from a Windows Box when I get home and see. I have already missed the assignment dates anyway, but I would still like to know why the cluster is behaving the way it is. I will post updates from a Windows Box, later.
Thanks much.

Hi , i am getting the same error pleasse. I have tried everything and still not able to connect to URI .

.env file:

Ticket: Connection

Rename this file to .env after filling in your MFLIX_DB_URI and your SECRET_KEY

Do not surround the URI with quotes

SECRET_KEY=hey_babe_its_me_lets_hangout
MFLIX_DB_URI=mongodb+srv://m220student:m220password@mflix.c9zff.mongodb.net/test
MFLIX_NS=sample_mflix
PORT=5000

error:
FAIL test/db-connection.test.js
Connection
× Can access MFlix data (9ms)
× Can retrieve a movie by id (16ms)
× Can retrieve first page of movies (9ms)

● Connection › Can access MFlix data

TypeError: Cannot read property 'db' of undefined

   7 | 
   8 |   test("Can access MFlix data", async () => {

//I am still getting able to access the database in IDE, i am able to see movies in sample_mflix db.

Please post a screenshot of the directory from where you are running the tests.

Please check the image and lemme know if I have done wrong somewhere! I have checked all the directory path and checked the DBs on IDE. But still getting the error… Please help!

The connection string is fine. The .env is fine. May be some requirements are missing. But I would have expect different error if that was the case. It might worth trying npm install again.

tried again, getting the same errors!!

Try removing the /test at the end of the connection string.

Tried ,still not working

I do not know the editor you are using but may be you have to explicitly save the .env after changing it.

Because on my installation with your connection string, it works.

I am using VSCode , which editor are you using? Did you get
any errors when you ran the test connection?