last day (15 days later) » 

6:49 PM
0
Q: Failing to connect to remote mongodb server

GleebI am trying to create a remote mongodb server to work with on my java project. I am using vagrant + ansible to create the environment, but fr soem reson i cannot get a connection. I always get connection refused through the network. the same code on localhost works perfectly. I am using vagra...

 
Can you telnet to the target address and port? telnet <ip-of-machine> 27017
 
no, that doesnt work: MacBook-Pro:~ me$ telnet 192.168.1.11:27017 192.168.1.11:27017: nodename nor servname provided, or not known. Ping works though
 
That's not right, don't use a colon between host and port when using telnet. telnet 192.168.1.11 27017
 
Sorry, but still doesnt work on connection refused. MacBook-Pro:~ me$ telnet 192.168.1.11 27017 Trying 192.168.1.11... telnet: connect to address 192.168.1.11: Connection refused telnet: Unable to connect to remote host
 
Yep, if you can't connect maybe you're trying to hit the wrong host. Your iptables rules look ok at first glance. Can you ping that host?
 
6:49 PM
yes ping works.
 
hey
 
Hi
:)
 
try turning off iptables for a sec to see if you can then telnet again
if youre on centos, service iptables stop
 
ok
still connection refused
 
it's possible your iptables rules are bad, those are always tough to get right :)
is mongo running on the host youre trying to connect to?
and are you sure the port is right?
 
6:51 PM
[root@localhost ~]# service mongod status
mongod (pid 2348) is running...
havent changed anything in the default settingds
 
lsof -i | grep 27017
 
so i assume this is the port
command not found
lson
 
huh, ok
 
f
 
ive never used mongo, so i cant help much there
 
6:52 PM
need to open them all
?
 
but it seems like your port is bad
im not sure
 
1 sec
can i try to connect with telnet to 127.0.0.1
27017
 
when youre on the remote server?
ah so your port is open, but for some reason you cant access it remotely
 
[root@localhost ~]# lsof -i | grep 27017
mongod 2348 mongod 8u IPv4 20429 0t0 TCP localhost:27017 (LISTEN)
 
yeah, that makes sense
so you do have the port right
 
6:55 PM
ye its something wired
i dont get it
i havent changed anything in the default installation
maybe i should try top open the other ports
but i dont think that thats the case
 
yeah, i dont think so
 
its a vagrant machine
maybe i can try and change that one
 
so there's something blocking remote traffic to that port
 
bad distribution
 
ive never used vagrant either, perhaps it has its own built in network security independent from iptables?
 
6:57 PM
i set the network there like i did on a mysql one that works fine
i use the public network one
and i can ping my machine from inside the vm as well
 
my gut is that there's some vagrant misconfiguration
i dont really know though since ive never used it
sorry i cant help more
good luck!
 
thanks
 
7:36 PM
hey gleeb
 

last day (15 days later) »