So I have setup a Bitnami EC2 mongoDB server. It is running, I can connect to it locally and I have inserted some documents and I am able to see my database and the documents using MongoDB Compass (through SSH tunnel). In the security group of my EC2 instance I allow all traffic from all ports (for test purposes). I have commented out also the bind_ip from the mongod.config file. However when running the following code
<?php
$key = '1234';
$m = new MongoClient("mongodb://xx.xxx.xx.xxx", array("username" => $bitnami",
"password" => $key));
?>
I get the following error "Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: xx.xxx.xx.xxx:27017: Connection refused'"
I have searched for possible answers and asked a similar question in stackoverflow before but it solved my problem only partially. I know the MongoClient command is deprecated but using the MongoDB\\Driver\\Manager I also cannot connect and no error message is shown. I hope somebody can help me with this, thanks in advance!
Godaddy restricts outgoing connection ports so you cannot connect from Godaddy to EC2.
Other useful references:
https://www.godaddy.com/community/Developer-Cloud-Portal/vps-outbound-port-restriction/td-p/3770
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.