How to connect to Openshift Mongodb from local client (ports are forwarded)?
I created a scaled nodejs app and added mongodb, everything works fine (connecting to mongodb from within nodejs using environment variables). Now I want to connect to the db from my local machine and I cannot get it to work for life.
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
It looks good as far as I can tell, not sure about the part Address already in use
.
When trying to connect from my machine via
mongo -u admin -p [password] --host [mysubdomain].rhcloud.com --port 65211 [dbname]
I just get
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 available ( ping
on the domain). I copied straight from rhc port-forward
. Does anyone have any experience with this problem?
source to share
rhc port-forward -a [myapp]
when this command is executed, all requests to localhost ie 127.0.0.1 will be sent to the remote host by the rhc tunnel.
so don't be confused, even if you see the remote host, try connecting to the localhost by default, the requests will be known to the remote server until you stop porting by pressing ctrl + c
mongo -u admin -p [password] --host 127.0.0.1 --port 65211 [dbname]
will solve your problem
source to share