Can't connect mongodb to mongolab - mongodb

So I am unable to connect to mongolab inside the mongo shell for some reason. In specifics, when I run mongo ds041643.mongolab.com:41643/teamsavage -u <dbuser> -p <dbpassword> inside the mongo shell, and ofcourse replace the brackets with my proper database credentials, as soon as I hit enter, it brings me to a new line with 3 dots and nothing after that.
I ran through the troubleshooting connections guide found under docs.mongolab.com/connecting/#help to try to figure the problem out and that did not help either.
I followed the guide step-by-step and the following occurred.
So it first said to ping the mongolab host, and I did with the following:
ping ds041643.mongolab.com and successfully got responses back
I then ran nc -w 3 -v ds041643.mongolab.com 41643 and got the following response back
Connection to ds041643.mongolab.com 41643 port [tcp/*] succeeded!
I am officially stuck with no further documentation to run through to fix my persistent problem. Please help!

Related

MongoDB: Atlas connection problems with Mongo Tools

Hey I am learning how to use a Mongodb Atlas using shell commands.
I can successfully connect to my Atlas cluster via Mongo Shell. Unfortunately I can't do it with Mongo Tools (mongoimport, mongoexport, mongostat).
If I execute this command:
mongostat --uri mongodb+srv://m001-student:m#####s#sandbox.####.###.mongodb.net
I receive:
error parsing command line options: error parsing uri:
lookup sandbox.#####.mongodb.net on 127.0.0.53:53: cannot unmarshal DNS message
The same problem repeat itself for other commands. I don't know if it is important but I use Ubuntu 18.04 on a uni network.
I tried to search for any solutions but I couldn't find anything useful. Changing resolv.conf as was suggested here did not achieve anything except cutting my network connection :P
Anyone have any idea?
Well it is more of a workaround than real answer but my solution is to not use command line tools provided by Atlas website and don't use srv connection.
mongostat --host "sandbox-shard-####.gcp.mongodb.net:27017,
sandbox-shard-####.gcp.mongodb.net:27017,
sandbox-shard-#####.gcp.mongodb.net:27017"
--authenticationDatabase admin --ssl --username ##### --password #####
Worked for me.

Trying to run my project on localhost – how can I use "mongod" command in Mac terminal instead of "sudo mongod"?

(NOT A DUPLICATE: This question title looks very similar to Dont want to have to start mongod with `sudo mongod`, but they are slightly different problems, and that question did not have any approved answers and I don't want to try something unapproved if I don't know what it will do.)
I am using mongodb and I am trying to run it on a localhost.
Supposedly, I should do $ mongod first in one terminal tab, then $ turbo devserver in another terminal tab, and this should run my project on a localhost.
However, when I try $ mongod, a bunch of text I don't understand shows up and in the midst of this text I see the following exception:
exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
However, when I instead do $ sudo mongod it runs perfectly and I can see my project data in the localhost. But I don't want to have to use sudo, I want to be able to just use the $ mongod command.
I looked around on stackoverflow and although there were similar problems (but with a different exception), nothing really helped me. I am very new to mongodb/APIs/JS/JSON/etc. so it was hard to understand what some of the other posts were talking about.
In a nutshell
What I'm trying to do:
Use $ mongod command on Mac terminal to set up database access
Use $ turbo devserver to successfully connect database to localhost
What is happening:
$ mongod command returns IllegalOperation exception
Therefore $ turbo devserver returns DB Connection Failed!
Database not connected, can't see project data in localhost
What I want to happen:
$ mongod to return waiting for connections on port 27017 ...
...which would make $ turbo devserver return DB Successfully Connected! ...
...which would show my project data in localhost
What I've tried:
Using $ sudo mongod instead, which works, but I want only $ mongod
Help is much appreciated. Thanks community!

Sequelize in Postgres Docker Image

I'm having trouble initializing a database with sequelize in my docker image. I keep getting a connection refused error because of the unix socket since I can't use localhost.
I've read how to create one with a script, but my project uses sequelize.
I've also tried various tactics with socket connections and using socat
psql commands will succeed in my init script, but the yarn command or sequelize commands end up with
ERROR: connect ECONNREFUSED 127.0.0.1:5432
My finial init script looks like this:
socat TCP-LISTEN:5432 UNIX-CONNECT:/var/run/postgresql/.s.PGSQL.5432 &
yarn --cwd /root db-create
The create command just calls dotenv sequelize db:create
I'm not really sure where to go from here. It seems like this should be a simple thing. Am I just missing something obvious?
-EDIT
It's worth pointing out that this was working fine with a postgres install. It was working fine when we just fired up postgres in the database and run the yarn commands after. The only difference here is we are trying to have the database created and migrated when the container starts so it's not a manual process.
If you bind to localhost you should be able to hit it at 127.0.0.1:5432
socat TCP-LISTEN:5432,bind=127.0.0.1,reuseaddr,fork UNIX-CLIENT:/var/run/postgresql/.s.PGSQL.5432 &

Clone Mongo DB from Server to localhost in Meteor App [Environment Variable]

I have a Meteor App running on Modulus.net server. The App is using by many people, So I want to use the same Database Locally. I'm using Ubuntu 12.
I read other SO Posts, but none of them found useful.
I tried this code
$ export MONGO_URL=mongodb://user:pass#mongo.onmodulus.net/dbId?autoReconnect=true&connectTimeoutMS=60000
$ meteor run
It throws an Error
Unexpected mongo exit code 45. Restarting.
Can't start mongod
MongoDB cannot open or obtain a lock on a file
I have also tried sudo mrt as I have installed meteorite, now the app is running but the database not changed.
I'm a newbie to Terminal, Is there any way to do that?
Did you replace user:pass and dbId to your username, password, and dbID?
You can use mongo mongodb://user:pass#mongo.onmodulus.net/dbId to check whether you can access it or not first.
Update
Sorry for the misleading answer, mongo shell has a bug to log in while you enter the url like so. You can see here
Your code runs successfully on my computer. You can try to delete .meteor/local and then execute meteor run again.
If you want to use sudo to execute it, add the argument -E so that the environment variables will not be reset:
sudo -E meteor run

mongoDB test error

I came to know about mongoDB and looked for test.So I made it install and then for test when I used command mongo on terminal it showed an error like this
MongoDB shell version: 1.8.2
connecting to: test
Sun Jul 31 01:06:07 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79
exception: connect failed
So can someone tell me what is the problem.I am using ubuntu 11.04.For installation instruction I had used this site.I am newbie to this mongoDB so please helpe me.Any help will be highly appreciable.
All you need to do is open 2 terminal tabs. In one, run
mongod
which starts the MongoDB server.
In the other, run
mongo
which is the shell that connects to your MongoDB server.
It looks like MongoDB isn't running. Can you connect to the web interface in your browser?
http://localhost:28017
Also, do you see the process running on your machine? You should see an entry for mongod when running ...
$ top
or
$ ps aux
why not install mongodb from 10gen's own debian repository? much easier and more likely to work
http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages
To see if mongodb is running, this also helps:
sudo service mongodb status
if it is running, and you still get the same error, then it must be the weird localhost bug that mongodb has. it assumes localhost is 127.0.1.1 for some reason. try
mongo 127.0.1.1
I had the same problem. Just try to create folder c:\data and next c:\data\db