Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialgagan singh
Full Stack JavaScript Techdegree Student 12,889 Pointsgetting failed connection
Gagans-MacBook-Pro:mongodb-osx-x86_64-3.4.4 gagansingh$ bin/mongo MongoDB shell version v3.4.4 connecting to: mongodb://127.0.0.1:27017 2017-05-08T15:28:43.859-0500 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused 2017-05-08T15:28:43.859-0500 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6 exception: connect failed Gagans-MacBook-Pro:mongodb-osx-x86_64-3.4.4 gagansingh$
10 Answers
Ken Alger
Treehouse TeacherGagan;
Do you have an instance of the MongoDB server running?
The mongo
command starts the mongo shell application which attempts to connect to a MongoDB server. You can start the server, if one isn't running already, with the mongod
command in a separate terminal window.
Post back if you are still stuck.
Ken
gagan singh
Full Stack JavaScript Techdegree Student 12,889 Pointswhen I try to do that it won't let me.. when I do Mongo or MongoDB to run the server.
Last login: Tue May 9 15:31:40 on ttys000 Gagans-MacBook-Pro:qa-rest-api gagansingh$ mongod -bash: mongod: command not found Gagans-MacBook-Pro:qa-rest-api gagansingh$
Ken Alger
Treehouse TeacherIf you are getting command not found
double check that it is in your PATH
variable and everything is installed correctly.
Which method did you use to install MongoDB?
gagan singh
Full Stack JavaScript Techdegree Student 12,889 Pointsthe mannual one that was shown in the vid by Huston here is the screenshot of the mongodb downloaded https://gyazo.com/52b49df7016e7c44c7e53e01267ebce0
Ken Alger
Treehouse TeacherIf you type in mongod --version
and mongo --version
what responses do you get, if any?
gagan singh
Full Stack JavaScript Techdegree Student 12,889 Pointsboth say not found when I type in the terminal should I go to the folder that mongo is downloaded to check the versions ?
Ken Alger
Treehouse TeacherYes. If it works there then the issue you are having revolves around the PATH
variable setting.
If it does not work there, then it likely is an issue with the downloaded files themselves.
gagan singh
Full Stack JavaScript Techdegree Student 12,889 Pointsye it wasn't working in both folder or any other file . not sure so should I unstall and reinstall everything and do you have the process to unstall and reinstall mongodb
Ken Alger
Treehouse TeacherNot specifically for your system, no. In the past I have just deleted all the files and cleaned up the PATH
variable. Then reinstalled.
But I've also never had the exact issue(s) you are experiencing.
Ken Alger
Treehouse TeacherGagan;
Were you able to resolve this issue?
Ken
gagan singh
Full Stack JavaScript Techdegree Student 12,889 Pointsno I been having a lot of issues with my pc I might have to do factory reset its a brand new Mac book pro hmm
Carrie Happoldt
15,160 PointsI had this exact same problem. You have to have two terminal windows open. one to run mongod (the server) and another to run mongo (the shell). to make a new window use command n OR to make a new tab use command t, inside the terminal. It took me 2 hours to figure this out. (grr...) I wish the video did a better job explaining this very important fact. I hope this helps the next person! good luck and happy coding!