title: Mongo connect failed
body: <p>I got following error while connectiong to mongodb</p>
  
  <blockquote>
    <p>MongoDB shell version: 1.6.5</p>
    
    <p>connecting to: test Mon Jan 31</p>
    
    <p>12:12:09 Error: couldn't connect to</p>
    
    <p>server 127.0.0.1 (anon):1154</p>
    
    <p>exception: connect failed</p>
  </blockquote>
  
  <p>I removed mongodb and re-install mongodb-stable
  It works fine for that day and next day got above error again.</p>
  
  <p>Few times I tried to  re-install mongodb-stable still getting same error.</p>
  
  <p>I am using latest pkg</p>
  
  <p>deb <a href="http://downloads.mongodb.org/distros/ubuntu" rel="nofollow">http://downloads.mongodb.org/distros/ubuntu</a> 10.4 10gen</p>
  
  <p>I tried another way i.e tried to connect to other machines mongodb
  i.e mongo otherMachinseIPAddress</p>
  
  <p>mongo connection done successfully</p>
  
  <p>But when i execute my program I got following error</p>
  
  <blockquote>
    <p>WARNING: jmx registration error,
    continuing
    javax.management.InstanceAlreadyExistsException:
    com.mongodb:type=ConnectionPool,host=tushar-desktop/127.0.1.1_27017
      at
    com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:467)
      at
    com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1520)
      at
    com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:986)
      at
    com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:938)
      at
    com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:330)
      at
    com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:516)
      at
    com.mongodb.DBPortPool$Holder.get(DBPortPool.java:62)
      at
    com.mongodb.DBTCPConnector._set(DBTCPConnector.java:458)
      at
    com.mongodb.DBTCPConnector.(DBTCPConnector.java:46)
      at
    com.mongodb.Mongo.(Mongo.java:137)
      at
    com.mongodb.Mongo.(Mongo.java:123)
      at
    com.mongodb.Mongo.(Mongo.java:90)
      at
    com.info.link.server.LinkedinServiceImpl.(LinkedinServiceImpl.java:40)
      at
    com.info.link.server.LinkedinServiceImpl$$FastClassByGuice$$d7de1b7.newInstance()
      at
    com.google.inject.internal.cglib.reflect.FastConstructor.newInstance(FastConstructor.java:40)
      at
    com.google.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
      at
    com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
      at
    com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
      at
    com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:758)
      at
    com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:804)
      at
    com.google.inject.InjectorImpl$4.get(InjectorImpl.java:754)
      at
    com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
      at
    com.info.link.server.cache.CacheHelper.(CacheHelper.java:30)
      at
    com.info.link.server.cache.CacheHelper$$FastClassByGuice$$35d2e084.newInstance()
      at
    com.google.inject.internal.cglib.reflect.FastConstructor.newInstance(FastConstructor.java:40)
      at
    com.google.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
      at
    com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
      at
    com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
      at
    com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:758)
      at
    com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:804)
      at
    com.google.inject.InjectorImpl$4.get(InjectorImpl.java:754)
      at
    com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
      at
    com.info.link.server.services.impl.CachingServiceImpl.(CachingServiceImpl.java:32)
      at
    com.info.link.server.services.impl.CachingServiceImpl$$FastClassByGuice$$de537f14.newInstance()
      at
    com.google.inject.internal.cglib.reflect.FastConstructor.newInstance(FastConstructor.java:40)
      at
    com.google.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
      at
    com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
      at
    com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
      at
    com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:758)
      at
    com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:804)
      at
    com.google.inject.InjectorImpl$4.get(InjectorImpl.java:754)
      at
    com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
      at
    com.info.link.server.services.impl.LenseServiceImpl.(LenseServiceImpl.java:37)
      at
    com.info.link.server.services.impl.LenseServiceImpl$$FastClassByGuice$$21e1222c.newInstance()
      at
    com.google.inject.internal.cglib.reflect.FastConstructor.newInstance(FastConstructor.java:40)
      at
    com.google.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
      at
    com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
      at
    com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
      at
    com.google.inject.FactoryProxy.get(FactoryProxy.java:56)
      at
    com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:758)
      at
    com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:804)
      at
    com.google.inject.InjectorImpl$4.get(InjectorImpl.java:754)
      at
    com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
      at
    com.info.link.server.callbacks.LenseCallbackImpl.(LenseCallbackImpl.java:30)
      at
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    Method)   at
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at
    java.lang.reflect.Constructor.newInstance(Constructor.java:532)
      at
    java.lang.Class.newInstance0(Class.java:372)
      at
    java.lang.Class.newInstance(Class.java:325)
      at
    org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
      at
    org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
      at
    org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
      at
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
      at
    org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at
    org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      at
    org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at
    org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      at
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at
    org.mortbay.jetty.Server.handle(Server.java:324)
      at
    org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      at
    org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      at
    org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      at
    org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at
    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      at
    org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      at
    org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)</p>
  </blockquote>
  
  <p>Please help me.</p>