I created a scaled nodejs application and added mongodb, everything is running fine (Connecting to mongodb from within nodejs using the environment variables). Now I want to connect to the db from my local machine, and I can't get it to work for the life of me.
rhc port-forward -a [myapp]
returns:
Forwarding ports ...
Address already in use - bind(2) while forwarding port 8080. Trying local port 8081
Address already in use - bind(2) while forwarding port 8080. Trying local port 8081
Address already in use - bind(2) while forwarding port 8081. Trying local port 8082
To connect to a service running on OpenShift, use the Local address
Service Local OpenShift
------- --------------- ---- -------------------------------------------------
haproxy 127.0.0.1:8080 => 127.2.114.130:8080
haproxy 127.0.0.1:8081 => 127.2.114.131:8080
mongodb 127.0.0.1:65211 => [mysubdomain].rhcloud.com:65211
node 127.0.0.1:8082 => 127.2.114.129:8080
This is looking good as far as I can tell, not sure about the Address already in use
part.
When trying to connect from my machine via
mongo -u admin -p [password] --host [mysubdomain].rhcloud.com --port 65211 [dbname]
I simply get a
Error: couldn't connect to server [mysubdomain].rhcloud.com:65211 (54.197.84.134), connection attempt failed at src/mongo/shell/mongo.js:148
exception: connect failed
So it just looks like that port is not reachable (ping
on the domain works). I copied straight from rhc port-forward
. Anybody having any experience with this issue?
Looks like you're connecting to the wrong host, you should be connecting to your localhost like this:
mongo -u admin -p [password] --host 127.0.0.1 --port 65211 [dbname]
rhc port-forward -a [myapp]
when the above command executed, all the requests to localhost i.e 127.0.0.1 will be forworded to the remote host by rhc tunnel.
so don't be confused, even you see the remote host, try to connect to the localhost by default the requests will be forword to remote server until the you terminate the port-forward by pressing ctrl + c
mongo -u admin -p [password] --host 127.0.0.1 --port 65211 [dbname]
will solve your problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With