We are trying to use ssh tunnel local port forwarding on aws ec2,that should forward the requests to DocumentDB.
sudo ssh -L 27777:docdbid***.docdb.amazonaws.com:27017 ec2-user@localhost -i "ec2keypair.pem" -N
Using netstat command(netstat -ano|grep 27777
),we got to know the port is listening on aws ec2.But,using telnet command from our machine and from our mongodb application,we get connection refused error when we try to connect to ec2 instance on 27777,where as we can ssh in to ec2 instance from our machine(ssh -i "ec2keypair.pem" ec2-user@ec2*****.compute.amazonaws.com
).With telnet command,we get exception as Could not open connection to the host, on port 27777: Connect failed
.The port is open in aws security group and also in our machine firewall inbound and outbound rules.Can anyone let us know the reason for the issue?