title: Can't connect to remote mongodb with mongo shell
body: <p>I am attempting to connect to a remote mongodb service and cannot figure out how to get it to work. The remote <code>mongod</code> is running on an Ubuntu box. I am a very novice unix user, but I'm reasonably certain the problem is that I am not opening up the firewall probably with <code>iptables</code>, I've tried the commands in the mongodb docs and still no success.</p>
  
  <p>mongodb.conf relevant rules</p>
  
  <pre><code>bind_ip = 0.0.0.0
  port = 27017
  auth = false
  </code></pre>
  
  <p>netstat -A</p>
  
  <pre><code>Proto Recv-Q Send-Q Local Address           Foreign Address         State
  tcp        0      0 *:28017                 *:*                     LISTEN
  tcp        0      0 *:27017                 *:*                     LISTEN
  </code></pre>
  
  <p>iptables -L -n</p>
  
  <pre><code>target     prot opt source               destination
  ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
  ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80
  DROP       all  --  0.0.0.0/0            0.0.0.0/0
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:27017 state NEW,ESTABLISHED
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:28017 state NEW,ESTABLISHED
  
  Chain FORWARD (policy ACCEPT)
  target     prot opt source               destination
  
  Chain OUTPUT (policy ACCEPT)
  target     prot opt source               destination
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp spt:27017 state ESTABLISHED
  </code></pre>
  
  <p>iptables commands executed as documented in mongodb docs at - <a href="http://docs.mongodb.org/manual/tutorial/configure-linux-iptables-firewall/#patterns" rel="nofollow">http://docs.mongodb.org/manual/tutorial/configure-linux-iptables-firewall/#patterns</a></p>
  
  <p>Here is what I've tried:</p>
  
  <p>browser: <a href="http://xx.xx.xx.xx:27017/" rel="nofollow">http://xx.xx.xx.xx:27017/</a> no response.</p>
  
  <p>browser: <a href="http://xx.xx.xx.xx:28017/" rel="nofollow">http://xx.xx.xx.xx:28017/</a> no response.</p>
  
  <p>browser: <a href="http://www.hostname.com:27017/" rel="nofollow">http://www.hostname.com:27017/</a> no reponse.</p>
  
  <p>browser: <a href="http://www.hostname.com:28017/" rel="nofollow">http://www.hostname.com:28017/</a> no response.</p>
  
  <p>mongo.exe xx.xx.xx.xx:27017 (remotely) <code>couldn't connect to server xx.xx.xx.xx</code></p>
  
  <p>mongo xx.xx.xx.xx:27017 (from localhost) connects properly</p>
  
  <p>mongo www.hostname.com:27017 (from localhost) connects properly</p>
  
  <p>The fact that it connects properly over localhost on the server hosting the mongodb, even when I specify the IP address, makes me think it has to be a firewall issue. Any ideas?</p>