Problem of connection 127.0.0.1:27017

nodejs
terminal
mongodb

#1

couldn’t connect to server 127.0.0.1:27017

Hi, developing a MEAN project. My mongoDB deployment is on mlab.com and as production I am connection to deployment, as a development connecting to local, actually trying to… As you can see the error, I got the same log after I write
> mongo on Terminal.

warning: Failed to connect to 127.0.0.1:27017,
Preformatted textreason: errno:111 Connection refused

Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed

I’d like to connect my localdb and also I wanna manage my deployment on Terminal. However I cannot connect my mongo shell.

Additionally:

I can connect my deployment on mongolab when I try this:

nodemon server.js

nodemon app.js

In these js files, connection string is defined and it both inserts and selects document from deployment on mlab.com without any errors. Still don’t understand why cannot connect local, mongo shell.


#2

did you try forcing the port to 8081? i know you are not trying to make a web service here, but i have had problems in the past with c9 and sockets other than 8080, 8081


#3

Thanks for reply. May I ask you where to change this information? Because I couldn’t find where it’s written. @Wambosa


#4

is mongo service running?


#5

@harutyun and @Wambosa;

MongoDB service DOES run on deployment but NOESN’T on local, giving the error above. Together with this, interesting, data can be written and read to and from the deployment with my mongolab connection string in app.js file when I type command > nodemon app.js on Terminal. (app.js file has both read, write, findOne methods in its independently)

The connection error occurs when I run the project by either typing > nodemon server.js on Terminal or opening URL on browser like https://myanotherproject-ludeveloper.c9users.io

Also there is another problem that my IDE doesn’t recognize angular definition written on top of js files under controller directory. But that’s another point. Let’s find and fix this up first!


#6

to connect to local mongo shell on 127.0.0.1, you need to run mongodb service locally.

Also there is another problem that my IDE doesn’t recognize angular definition written on top of js

could you show an example of a file which is not recognized correctly?


#7

Thanks @harutyun, details of my question to 2nd point is as follows:

this is screen from a js file under ‘controller’ directory.

It comes to me that, IDE cannot recognize angular codes so that I cannot display all different .jade/.html files in a single page. I made them to be seen in a single page, however the only thing seen on the page is codes written inside of index.jade file. Normally on top-right corner there must be login panel, but not seen there!

huh, it’s tough at all!


#8

you can add /global angular/ at the top of the file, or add angular to .eslintrc see http://eslint.org/docs/user-guide/configuring#specifying-globals