cannot connect to MongoDB, Ubuntu 64 VM ( Vagrant, PuPHPet ) - mongodb

Downloaded and tried a couple of different versions from puphpet.com just to be sure. Here is the mongo part of code from puphpet config.yaml:
mongodb:
install: '1'
settings:
auth: 1
port: '27017'
databases:
kxuqYQ6plcMS:
name: awesome
user: admin
password: '1234'
IMPORTANT ! I can run mongo in git shell, and mongod service is running, but cannot access it from outside.
mongodb conf :
bind_ip = 0.0.0.0
port = 27017
auth = 1
I've tried commenting the bind_ip, without success. During Robomongo connection i also tried with ssh, specifying
SSH_adress = 127.0.0.1:22
username = vagrant
password = vagrant
and also authentication, but that does not matter since it cannot connect

The same was happening to me.
I added the following lines at the end of the Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 27017, host: 27017
end
And changed in /etc/mongodb.conf bind_ip to 0.0.0.0
bind_ip = 0.0.0.0
Restarted mongodb and after that I could connect to it through the host and Robomongo

I think the issue is probably that you did not add the Mongo port to the firewall section. The port is accessible from inside the VM, but anything outside of it needs to be cleared by iptables.
Just add to the firewall section within your config.yaml

Related

How to set up mongoDB bindIp?

Something wrong happens when I'm trying to setup mongod.conf for connection from remote server.
When I paste my server ip address Mongo doesn't allow connection from it.
# network interfaces
net:
port: 27017
bindIp: 111.111.11.111 #my server ip
When I allow connection from any server, mongo allows to connect from my server.
net:
port: 27017
bindIp: 0.0.0.0
I want to have an access to Mongo from localhost and from my server. I'm trying to paste these ip's both but Mongo allow connection from localhost only.
net:
port: 27017
bindIp: 127.0.0.1 111.111.11.111
What's wrong and how to use bindIp ?
According to documentation the value is a string, i.e. a single value.
Try following:
Use only 111.111.11.111, localhost may work by default anyway.
Try these ones:
net:
port: 27017
bindIp:
- 127.0.0.1
- 111.111.11.111
net:
port: 27017
bindIp: 127.0.0.1,111.111.11.111
net:
port: 27017
bindIp: [127.0.0.1,111.111.11.111]
Otherwise use a firewall, either an external one or the internal firewall of your operating system.
I thought there has to be the IP address of the remote server. It's not right. There can be ip addresses of the network interfaces of the current machine.
Looking for here:
ifconfig -a | grep "inet"

How to connect mongoDB Compass to mongoDB container which runs in azure VM?

I have mongoDB container which runs on azure VM, and I'm trying to connect it to my mongoDB compass.
I have Public IP address to my VM, the port 27017 is open in my vm and also in my mongo container.
I have authentication, so to connect my mongo I'm Enter the mongo container and write the command "mongo -u username -p password --authenticationDatabase admin" (Relevant).
When I'm trying to connect I get "connection timed out" error message.
docker container ls
Open ports on the VM
My compass login page
I solved it by changing the configuration file of the mongoDB container.
Step 1:, make sure port 27017 is open on the VM:
Step 2:, create a mongoDB configuration file as below, name it mongod.conf, and change the bindIp field to your host IP (change < Host IP> to your host IP).
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /data/db
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,<Host IP>
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Step 3: Copy the mogod.conf file into your VM, and save it wherever you want.
Step 4: Run the command:
docker run -d -v <FolderPathOnTheVM>/mongod.conf:/etc/mongod.conf -p 27017:27017 mongo -f /etc/mongod.conf
Make sure you changed the < FolderPathOnTheVM> to the path of the mongod.conf file on the VM (The path of step 3).
Do netstat on 27017 and check if its running on localhost or public IP. If its running on localhost, then change it to your public IP in mongodb config file and then retry. Also, telnet from your local machine to the mongodb IP and port to check if its working locally.

How to configure PostgreSQL ODBC Driver

I have a database on Crate DB. The database program is started through docker-compose.yml file. It is running on http://192.168.99.100:4200 (this is the docker machine's IP with the Crate's port)
I want to connect the Crate DB with Power BI. When I try to configure the PostgreSQL ODBC Driver, I don't know what to type on "Server" field.
So far I've tried "localhost", "127.0.0.1","0.0.0.0", "192.168.99.100" but none of these works.
So my question is, which IP address should I type on the "server" field?
The setup seems correct. Make sure the port 5432 is correctly published. Assuming you're using the official cratedb image, the exposed ports in Dockerfile used to assemble the image are the following:
# http: 4200 tcp
# transport: 4300 tcp
# postgres protocol ports: 5432 tcp
EXPOSE 4200 4300 5432
Therefore, in order to access those services remotely you have to publish their corresponding ports. In docker-compose.yml configure the port mappings if you haven't already done so:
version: "3.5"
services:
cratedb:
image: crate
ports:
- 5432:5432
- 4200:4200
- 4300:4300
More about port mappings in the ports section of the Compose file reference. Now you should be able to connect using the ODBC PostgreSql driver to the IP address of the host (i.e. 192.168.99.100) and port 5432.
In alternative you could run the container with port bindings:
docker run -d -p 4200:4200 -p 5432:5432 -p 4300:4300 crate
If you still can connect to the database, check the firewall settings.

Why Mongodb config changes not getting applied?

I am running Mongodb on AWS windows instance, I changed my config setting as following:
net:
port: 30000
bindIp: 0.0.0.0
As far as my knowledge, Server should get started on port 30000, it can listen request from other ip as well
However, on restarting mongod, it is still running on localhost and listening to port 27017
I have the same problem with you. What I did is a workaround it. I start the service with specifying the port and ip.
mongod --auth --port 30000 --dbpath /data/db --bind_ip_all

How to configure new port for mongodb

I am currently using port 27017 for mongodb and everything is working proper. We want to configure new port for security purpose.
Can you help me how we can configure this?
This way,
While startiing mongo pass port argument
mongod --port your desired port
mongod --port 19000
Start Mongo with port:
mongo --port your desired port
mongo --port 19000
2.change the port in the mongodb.config file and pass the config file as input.
port = Ur desired port
Change the /etc/mongod.conf file for persistence
change net: section as
net:
bindIp: 127.0.0.1
port: <The port number you want to listen>
Command line option --port <port> can also be used but will not remain persistent and you need to specify the same every time you start Mongod