Why can I connect to '127.0.0.1' but not 'localhost' when no internet connection is present in MongoDB compass? - mongodb

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).

Related

Connect to localhost PgAdmin server from remote computer

I have a PgAdmin server running on localhost and I'm trying to connect to it from another computer on the same network (they have the same IPv4 address).
I've gone through a lot of questions but all of them explain how to connect to a remote server, which I assume is running on an available host.
I've tried:
adding listen_addresses = '*' to postgresql.conf (on both computers)
adding host all all 0.0.0.0/0 md5 to pg_hba.conf (on both computers, replacing 0.0.0.0/0 with a variety of ip addresses)
some other things I saw in tutorials but don't remember
What I'm trying to understand is:
Is it possible to connect remotely to a server running on localhost?
If it is possible, which IP address does the remote computer need to connect?
You need to resolve some basic questions first:
What is the IP of the computer where PG is running? e.g. 192.168.100.10
Which port is PG exposed on? e.g. 9999
After you collected the two above information you can go on the second computer where you have pgAmin and execute
telnet <host> <port>
substituting <host> and <port> with the info collected above. If telnet replies with
Trying ::1...
Connected to <host>.
Escape character is '^]'.
this should mean that the port is open and PG should be listening on that host:port. You found your connection string to PG!
I am just sharing my understanding here. Corrections are welcome.
pgAdmin can connect to one/more postgres servers via TCP over using JDBC like protocol. pgAdmin is just a stand-alone web-interface ( web adapter ).
So some web-server configuration/tuning should be needed in pgAdmin configuration to enable access from remote machines.

MongoDB: Connect to localhost from another computer in same network

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.

php: fbird_connect(): Unable to complete network request to host "localhost". Failed to establish a connection [duplicate]

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

MongoDB remote connection

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)

Why mongoDB built-in http stats interface on port 28017 doesn't work at all?

Well guys, I'm trying to get that MongoDB feature working for hours:
http://www.mongodb.org/display/DOCS/Http+Interface
I start mongod with external configuration file on Mac OS X platform. Almost all the settings in the config file is default. I've turned of the authentication and make sure http interface is on :
nohttpinterface = false
MongoDB starts successfully and does it's job. And just to make sure that it listens on port 27017, I do following:
(web)Roy-MacBook:/ roy$ curl localhost:27017
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
which is fine. And I try to check the same thing for the port 28017:
(web)Roy-MacBook:/ roy$ curl localhost:28017
curl: (7) couldn't connect to host
Even though with telnet:
(web)Roy-MacBook:/ roy$ telnet localhost 28017
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
I don't know if I have to tell that I've tried with a browser. I don't run any custom web or any other server that blocks the port 28017. I could only find one bug here:
https://jira.mongodb.org/browse/SERVER-2917
but it is related with --auth command that I don't use nor I have any user show out of "db.system.users.find()".
One strange thing is when I turn on mms-name, mms-token or mms-interval in configuration as shown as their config reference here (www.mongodb.org/display/DOCS/File+Based+Configuration), mongod gives following error:
error command line: unknown option mms-name
use --help for help
I though that might be the relative problem.. Any opinion will be appreciated, thanks.
This looks like a bug in the config parser. Take this line OUT of your config file:
nohttpinterface = false
When I added that line it turned the HTTP interface off on my Mac even though it's set to false.