I'm running MongoDB on one computer and want to connect to the server instance from another computer on the same network.
Going into Mongo shell gives me the following output for both computers: connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb with a different instance: Implicit session: session { "id" : UUID(...) }.
I tried the proposed solutions from here and here to no avail. Thought that binding the IP to 0.0.0.0 would help, but it didn't.
Any additional suggestions from someone who dealt with a similar issue?
0.0.0.0 is an address, not a port. You need to configure the server to listen on all addresses or explicitly on loopback (127.0.0.1) and the network address (whatever it is), then configure the client to connect to the server's address.
Use netstat on the server side to verify the server is listening on your configured addresses.
Related
I'm trying to connect to a remote Firebird database "test" (alias already added). It is not an embedded server, and is installed on VM with IP 192.168.1.147.
Here is my connection string:
User=sysdba;Password=masterkey;Database=test;DataSource=192.168.1.147
However I got an error:
FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Unable to complete network request to host "192.168.1.147". ---> Unable to complete network request to host "192.168.1.147".
I've done some research on that but haven't got a clue yet. Some help needed. Thanks
My IP address is 192.168.2.108, and I can ping that server IP successfully
Make sure that
Firebird is running
Firebird is listening on port 3050 on the specified IP (or on 0.0.0.0)
Your firewall allows access to port 3050
You're using the correct host name
For Linux, the Firebird port is closed by default. You need to modify RemoteBindAddress in /etc/firebird/2.5/firebird.conf from
RemoteBindAddress = localhost
to
RemoteBindAddress =
and restart service.
Make sure you have excluded tcp port 3050 in VMs' firewall.
Ok. I think your connection to firebird is faililing because the firebird client looks up the network service file by name and does not find gds_db in the services file.
If your connection string refers to the host by using IP, the Client might fail to identify it because it gethostbyname() and not by IP
Manually include this in the file and you should be fine.
C:\windows\system32\drivers\etc\services
I am curious why I can connect to the localhost server by specifying the loopback IP address (127.0.0.1) but not using the name 'localhost', when no internet connection is present in mongoDB compass? When I try to connect with the domain name I get the following error:
getaddrinfo ENOTFOUND localhost localhost:27017
I'm guessing the domain name lookup process is requiring the internet in order to convert localhost to 127.0.0.1. Not sure if I'm on the right track or not.
When you are connected to the internet the DNS service of your device handles the resolution of localhost. When you are not connected to the device the only way for your machine to know about the name localhost is the /etc/hosts file (or C:\Windows\System32\drivers\etc\hosts if you're running windows, latest versions of windows although might resolve localhost without using the hosts file).
When I start MongoDB using mongod.exe it displays a message like "waiting for connections on port 27017", but when I execute mongo.exe the log message is "connection accepted from 127.0.0.1:60501".
Now, when I use PyMongo to connect to the DB I assumed that the port number to be used is "60501" since this is the port where the connection was established. Surprisingly I got an error saying "connection refused". I thought there was some problem with my MongoDB installation, config file placement, etc.
When nothing fixed it, I just played around by changing the port number to 27017, and this actually fixed the problem. Can someone explain how this worked out?
This behaviour is not specific to MongoDB. As part of the TCP/IP client/server protocol, services listen on configured ports (typically with well known defaults like 27017 for mongod). Clients connect to a server port and also establish their own ephemeral/dynamic port to use for the duration of a client/server session.
Each active session from the same client IP will use a distinct port on the client. The ephemeral port is logged to identify different client connections as they are established.
The logging in your case might be slightly confusing since you are connecting from localhost (127.0.0.1) where the server is also running, but the correct port to connect to is the mongod server port (default: 27017).
I have an Ubuntu server with mongodb installed. Is it possible to configure mongodb in such a way that I can connect to it using only localhost and its LAN IP address.
The default mongo configuration works fine for connecting using localhost:
bind_ip = 127.0.0.1
If I change to the LAN IP, then I am only able to connect using that IP, and not using localhost:
bind_ip = 10.10.10.10
If I try to add both, then I get an address in use error and doesn't start:
bind_ip = 127.0.0.1, 10.10.10.10
If I remove the bind_ip setting, then both work, but I am also able to connect with the servers external IP (which I do not want).
#bind_ip = 127.0.0.1, 10.10.10.10
So, how can I tell mongo to listen on the local interface, but allow connections from both localhost and its LAN IP?
With the help of #wdberkeley's comment, I realized that the problem was the space after the , in the list of IP addresses the bind to. However, it seems that this issue only affects the old config file format (not YAML).
# This Works:
bind_ip = 127.0.0.1,10.10.10.10
# This doesn't work:
bind_ip = 127.0.0.1, 10.10.10.10
Bind to address 0.0.0.0 this will allow it to answer regardless of the IP address being used and even on machines that have multiple network cards with different IP addresses
I am trying to use MongoDB for remote connection. First I tried localhost and internal ip address to build the connection. Both of them succeeded. Then I tried external ip address to connect on my own computer of MAC as an experiment first. I have created an admin user for the database in MongoDB. The bind_ip option is also commented in mongodb.conf. The firewall should also have been turned down. But the connection cannot been built still. Does anyone know the reason?
Thank you very much!
To allow connecting remote clients (which is your case) to MongoDB Server.
Make sure to do set bind_ip to either of values, in your mongodb.conf file -
Following is with any IP
bind_ip = 0.0.0.0
Following for bind to specific IP
bind_ip = 10.52.36.99 (or any specific IP)