Unable to connect to host on different system from mongo shell in windows - windows

I am trying to connect to mongodb from my system to different system but i am getting following error-
MongoDB shell version v3.4.5
connecting to: mongodb://192.168.0.152:27017/
2017-06-23T18:06:50.643+0530 W NETWORK [thread1] Failed to connect to 192.168.0.108:27017 after 5000ms milliseconds, giving up.
2017-06-23T18:06:50.644+0530 E QUERY [thread1]
Error: couldn't connect to server 192.168.0.152:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
exception: connect failed
I tried various solutions listed on stackoverflow but didn't find any solution yet.
Can somebody please help me out?

getaddrinfo() resolves domain names through the DNS protocol (which is not related the Netbios Naming System - reason why writing a Windows PC Name is usually a bad idea). Depending of the underlying implementation of the function it might or might not be able to resolve Netbios Names.
Usually using a Netbios computer name is a bad idea, you should rely on a proper DNS architecture.
If you have the exact same error with a mongodb:// URL using solely an IP address, it's weird... Please provide more details on the IP address try case.
Also ensure that the server is not firewalled. Try a netcat connection using netcat for windows:
nc IP 27017 -vv
should say 'Connected'
Netcat for Windows: https://eternallybored.org/misc/netcat/

To be able to connect to mongodb server hosted in another machine, you should be sure that your mongodb server allows connections from addresses other than 127.0.0.1
In the mongod.conf there should be some network interfaces configuration:
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
To allow any machine to connect to your server the bindIp should be set to: 0.0.0.0

Related

Windows - jboss on docker, connection refused to local oracle database

I have Jboss running in a docker container. On jboss I have defined a connection to the xa-datasource database as the ip address of my computer and not localhost because I work in Windows 10. Despite the correct ip and port to the database (oracle) I keep getting the connection refused error. I run jboss with the command
docker run -d -p 8080:8080 -p 9990:9990 myjboss
Can anyone help me, or do I need any additional settings in my docker. I will add that I also test alpine and in the container (exec) I can ping my ip address.
Thanks a lot for all the answers. I would like to add that I tested all other solutions contained in similar questions, but unfortunately I did not get the expected results.
If you can ping your host IP, but you can’t connect to the database, granted that the DB is running and the listener is up...
I’d advise you to check the Windows Firewall settings.
Maybe try disabling it to check if you can actually connect to the database, if so, add an Inbound Rule to the firewall to allow connections on port 1521 (or whatever port your listener is running on)
I solved this problem by using not ip/localhost but host.docker.internal as described here -> https://docs.docker.com/docker-for-windows/networking/

Access public PostgreSQL server (Amazon RDS) from personal computer through proxy

I'm new to Amazon Web Service (AWS).
I already created a PostgreSQL from AWS RDS:
Endpoint: database-1.XXX.rds.amazonaws.com
Port: 5432
Public accessibility: Yes
Availablity zone: ap-northeast-1c
After that, I will push my application that using the database to AWS (maybe deploy to EKS).
However, I want to try testing the database server from my local computer first.
I haven't tried testing from my laptop PC at home yet, but I think it will connect OK because my laptop PC is not using the HTTP proxy to connect to the network.
The problem is that I want to try testing from my company PC, which needs setup the HTTP proxy to connect to the internet. The PC spec:
Windows 10
Installed PostgreSQL 10
Firstly, I tried using psql command-line:
psql -h database-1.XXXX.rds.amazonaws.com -U postgre
> Unknown host
set http_proxy=http://user:password#my_company_proxy:3128
set https_proxy=http://user:password#my_company_proxy:3128
psql -h database-1.XXXX.rds.amazonaws.com -U postgre
> Unknown host
set http_proxy=http://my_second_company_proxy:3128
set https_proxy=http://my_second_company_proxy:3128
psql -h database-1.XXXX.rds.amazonaws.com -U postgre
> Unknown host
Then, I tried using the pgAdmin tool.
As from the internet post, it said that we can use "SSH Tunnel" for inputing proxy:
However, the error message will be shown:
So, anyone can help suggest if we can connect to the public PostgreSQL server through HTTP proxy?
I think problem is Postgres uses plain TCP/IP protocol and you are trying to use HTTP proxy. Also you're trying to create SSH tunnel against your HTTP proxy server which won't work.
So I'd suggest following solutions:
Use TCP proxy instead of HTTP proxy
Create an EC2 or any instance that has SSH access from your company network and has access to public internet. So that you can create SSH tunnel through that instance to achieve your goal.
NOTE: Make sure you PostgreSQL is accessible from public internet (although this is usually bad idea, but it's out of scope this question) sometimes security group configs prevent it to connect from public internet.
Just add all ports(5432,3128...) in the Security Group from your RDS and specify your IP. Don't forget "/32"
Let me add that "unknown host" is usually an indication that you're not resolving the DNS hostname. Also, your HTTP proxy should not interfere with connections to databases since they aren't on port 80 or 443. A couple of things you can try (assuming you're on windows) sub in your actual url:
nslookup database-1.XXXX.rds.amazonaws.com
telnet database-1.XXXX.rds.amazonaws.com 5432
You should also check the security group that is attached to your RDS and make sure you've opened up the ip address that you're originating from on port TCP/5432.
Lastly check that your VPC has DNS and Hostnames enabled. https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#vpc-dns-updating

certbot cannot verify domain and connection refused

I am trying to generate certificate for my domain. I can ping my domain but still getting error. I have added inbound firewall rule to my digital ocean server to accept port 80 on ipv4 and ipv6 as well. Not sure what is wrong. [Note: my nginx server is not running as I cannot get the certificate]
https://community.letsencrypt.org/t/invalid-response-404-nginx-docker-container/102525
My domain is: www.1040nra.com
I ran this command: sudo certbot certonly --staging --webroot -w /root/dt-app-data/ -d 1040nra.com -d www.1040nra.com
It produced this output:
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for 1040nra.com
http-01 challenge for www.1040nra.com
Using the webroot path /root/dt-app-data for all unmatched domains.
Waiting for verification…
Cleaning up challenges
Failed authorization procedure. 1040nra.com (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://1040nra.com/.well-known/acme-challenge/22AD-KFmF62z373CPiUKzk6dlr-0s5wMOmnmrziMqd4: Connection refused, www.1040nra.com (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://www.1040nra.com/.well-known/acme-challenge/ba-jjDhBUZJ9fHLofGfDYSVV5a-ETlX26A64A-2Yu0s: Connection refused
IMPORTANT NOTES:
The following errors were reported by the server:
Domain: 1040nra.com
Type: connection
Detail: Fetching
http://1040nra.com/.well-known/acme-challenge/22AD-KFmF62z373CPiUKzk6dlr-0s5wMOmnmrziMqd4:
Connection refused
Domain: www.1040nra.com
Type: connection
Detail: Fetching
http://www.1040nra.com/.well-known/acme-challenge/ba-jjDhBUZJ9fHLofGfDYSVV5a-ETlX26A64A-2Yu0s:
Connection refused
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you’re using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.
My web server is (include version):
The operating system my web server runs on is (include version): ubuntu 18.04
You seem to have solved the problem yourself.
This is because the certbot domain cannot verify the DNS A record.
Make sure your domain address is directed to your server's ip address.
If you made the dns change 'recently', it may take some time to delete the old ip address.
https://www.whatsmydns.net/
Check here, there should only be one IP address and this should be your server's IP address.
Make sure ports 80 and 443 are open by running the command below:
sudo ufw status
If port 443 is not open, then run the command bellow to allow port 443:
sudo ufw allow https
Issue: The issue is your domain might be not pointing to your Cloud host IP and DNS setup
Solution:
You have to map your domain and IP in-network option tab A
Once you did the mapping then you have to setup DNS on where you have purchased the domain website.
Then check by entering your domain name on this web site www.whatsmydns.net showing your IP address or not
If Yes then you create the certificate
Go to the https://www.whatsmydns.net/
Enter your host name
You set the type A
Make sure that there is the same IP everywhere
You set the type AAAA
Make sure there are no AAAA entries
AAAA are IPv6 entries.
If the addresses for AAAA are present, make a request to this IPv6 address
#example curl [43ff:0c89:eb10:4c06:c90e:4b7d:64e5:fbe1]
curl [your IPv6]
If you get an error, then the address does not point to your site. Accordingly, there is a difference between IPv4 and IPv6.
Solution: delete the domain zone type AAAA

SQL*Plus connection SetUp: ORA-12154 Error

Sorry for the noob question but I am new to Oracle SQL software.
I've been trying to create a connection to my database student (created on SQL Developer), but got quite confusing since I'm using a client-computer which will connect to server.
Below are the info about the connection:
Connection Name: LARGER123
Username: LARGER123
Hostname: uxkg265.admin.plent
Port: 1520
SID: ticp5076
Client-computer username: r5678
When I open the SQL Plus prompt, I tried several combinations on the username in order to establish the connection, but got the same error ORA-12154 Error.
I though that it could be the way I was setting the things on username field, so I followed the instructions from Oracle's website:
https://docs.oracle.com/database/121/ADMQS/GUID-1A15D322-B3AC-426A-86A1-EB7590930687.htm#ADMQS045
Basically it tells to "build" the username structure in that way:
nick#"dbhost.example.com/orcl.example.com"
Where: "nick" is the user; "dbhost.example.com" is the host; and "orcl.example.com" is the database.
So, following the example I put my username in that way and got errors:
LARGER123#"uxkg265.admin.plent/student"
I tried different ways, including the Port and SID but got no success.
Do you have a better idea of what's my mistake?
Are you quite certain somebody is listening where you are trying to connect. I would suggest you start by testing with telnet.
You say your server has the domain name “uxkg265.admin.plent”
nslookup uxkg265.admin.plent
I just checked my IP address and found:
$ nslookup $(hostname)
Server: xxx.xxx.xxx.xxx
Address: xxx.xxx.xxx.xx##53
Name: mydomain.myorg.com
Address: 192.168.56.1
I just tried to connect to my oracle instance and got:
$ telnet 192.168.56.1 1521
Trying 192.168.56.1...
Connected to 192.168.56.1
Escape character is '^]'.
^]
telnet> quit
Connection closed.
If I try to the wrong port, I get:
$ telnet 192.168.56.1 1522
Trying 192.168.56.1...
telnet: connect to address 192.168.56.1: Connection refused
I was able to connect with:
sqlplus myoracle/testpass#192.168.56.1:1521/UPGR
where UPGR is the service name.
I was also able to connect with:
sqlplus myoracle/testpass#"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.1)(PORT=1521))(CONNECT_DATA=(SID=UPGR)))"
With UPGR as the SID.
I had some trouble initially because my version of Oracle Linux had iptables enabled and that was keeping me from connecting using sqlplus. As soon as I disabled this protection, I was able to use Oracle.
sudo service iptables stop
sudo chkconfig iptables off
(Keep in mind that iptables serves a purpose. For my test system running on my PC in VirtualBox, turning it off is fine. For other systems, maybe not.)
ORA-12154 is TNS:could not resolve the connect identifier specified, but you likely aren't using TNS to resolve the connect identifier: have you edited the tnsnames.ora file on the client machine and created an entry for the SID you're trying to connect to? Probably not.
Instead of selecting SID, select "Service name" and put the Oracle SID there. With the "Basic" connection type, that should use the host/port and service name explicitly to build the connection rather than relying on TNS to look up (resolve) the SID.

Postgres: Unable to connect to domain socket

Running psql gets me this:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I installed Postgres 9.3.3 using Homebrew.
which psql gives /usr/local/bin/psql
This seems to be a common issue. I'm terribly sorry to ask again, but I've gone through at least a dozen Q&As here and can't resolve the issue. A few posts I've gone through include:
Why am I getting a could not connect to server error for postgres in Mac OS Lion?
Postgres cannot connect to server on Unix domain socket 5432
Can not connect to local PostgreSQL
Many thanks,
Justin
Have you modified postgresql.conf to accept incoming TCP/IP connections? You should uncomment the listen_addresses parameter and set it to an appropriate subnet mask. Then in pg_hba.conf you have to add a line to enable connections to databases over TCP/IP. Both configuration files are in your data directory (don't know where that is on OSX).

Resources