title: Mongodb no route to host while running mongo on a local machine
body: <p>I have installed MongoDB on a local machine by following <a href="http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/" rel="nofollow">this</a> tutorial and <a href="http://tecadmin.net/install-mongodb-on-ubuntu/#" rel="nofollow">this</a> one as well. I used my local user (using sudo in all commands) and then I do:</p>
  
  <pre><code>sudo service mongod start
  </code></pre>
  
  <p>It says <code>start: Job is already running: mongod</code>. Then when I run this command</p>
  
  <blockquote>
    <p>sudo mongo</p>
  </blockquote>
  
  <p>I get </p>
  
  <blockquote>
    <p>MongoDB shell version: 2.6.0
    connecting to: test
    2014-07-08T12:33:40.360+0200 warning: Failed to connect to 127.0.0.1:27017, reason: errno:113 No route to host
    2014-07-08T12:33:40.361+0200 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
    exception: connect failed</p>
  </blockquote>
  
  <p>THis is also the output of <code>netstat -tpln</code></p>
  
  <pre><code>(No info could be read for "-p": geteuid()=1000 but you should be root.)
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
  tcp 
  
     0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      -
  </code></pre>
  
  <p>Also this is the output of  <code>sudo /sbin/iptables -L -n</code></p>
  
  <pre><code>Chain INPUT (policy DROP)
  target     prot opt source               destination
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:80
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:5432
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:8080
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:8443
  ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:3306
  ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 255
  ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
  REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
  ACCEPT     tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:27017 state NEW,ESTABLISHED
  ACCEPT     tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:27017 state NEW,ESTABLISHED
  ACCEPT     tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:27017 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            127.0.0.1            tcp spt:27017 state ESTABLISHED
  ACCEPT     tcp  --  0.0.0.0/0            127.0.0.1            tcp spt:27017 state ESTABLISHED
  ACCEPT     tcp  --  0.0.0.0/0            127.0.0.1            tcp spt:27017 state ESTABLISHED
  </code></pre>
  
  <p>I have followed several proposed solutions and never worked. Any suggestions?</p>
  
  <p>I have followed several proposed solutions and never worked. Any suggestions?</p>