java.rmi.ConnectException

Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out]

Samebug tips4

Check if your MongoDB is available.

Check if your server (or a proxy server) is not going up and down. There might be something between a proxy and a client sending intermittent requests to non-functioning hosts as well. There might as well be too many requests in a short amount of time.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web456

  • via Stack Overflow by del
    , 6 months ago
    Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out
  • via Google Groups by Sergey Gerasimenko, 9 months ago
    Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out]
  • via Oracle Community by 2977838, 4 months ago
    Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out
  • Stack trace

    • java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.red5.server.Launcher.launch(Launcher.java:69)[red5-server.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.7.0_111] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[na:1.7.0_111] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.7.0_111] at java.lang.reflect.Method.invoke(Method.java:606)[na:1.7.0_111] at org.red5.server.Bootstrap.bootStrap(Bootstrap.java:123)[red5-service.jar:na] at org.red5.server.Bootstrap.main(Bootstrap.java:48)[red5-service.jar:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jmx.support.ConnectorServerFactoryBean#0' defined in class path resource [red5-common.xml]: Invocation of init method failed; nested exception is java.io.IOException: Cannot bind to URL [rmi://localhost:9999/red5]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.red5.spring.Red5ApplicationContext.refresh(Red5ApplicationContext.java:36)[red5-server.jar:na] at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.afterPropertiesSet(AbstractRefreshableConfigApplicationContext.java:151)[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.red5.spring.Red5ApplicationContext.afterPropertiesSet(Red5ApplicationContext.java:30)[red5-server.jar:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] ... 16 more Caused by: java.io.IOException: Cannot bind to URL [rmi://localhost:9999/red5]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out] at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:826)[na:1.7.0_111] at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:431)[na:1.7.0_111] at org.springframework.jmx.support.ConnectorServerFactoryBean.afterPropertiesSet(ConnectorServerFactoryBean.java:188)[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] ... 30 more Caused by: javax.naming.ServiceUnavailableException: null at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:143)[na:1.7.0_111] at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:226)[na:1.7.0_111] at javax.naming.InitialContext.bind(InitialContext.java:419)[na:1.7.0_111] at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:643)[na:1.7.0_111] at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:426)[na:1.7.0_111] ... 33 more Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection timed out at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)[na:1.7.0_111] at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)[na:1.7.0_111] at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)[na:1.7.0_111] at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)[na:1.7.0_111] at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)[na:1.7.0_111] at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:137)[na:1.7.0_111] ... 37 more Caused by: java.net.ConnectException: Connection timed out at java.net.PlainSocketImpl.socketConnect(Native Method)[na:1.7.0_111] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)[na:1.7.0_111] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)[na:1.7.0_111] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)[na:1.7.0_111] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[na:1.7.0_111] at java.net.Socket.connect(Socket.java:579)[na:1.7.0_111] at java.net.Socket.connect(Socket.java:528)[na:1.7.0_111] at java.net.Socket.<init>(Socket.java:425)[na:1.7.0_111] at java.net.Socket.<init>(Socket.java:208)[na:1.7.0_111] at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)[na:1.7.0_111] at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)[na:1.7.0_111] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)[na:1.7.0_111] ... 42 more

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    124 times, 2 hours ago
    18 times, 12 hours ago
    47 times, 1 day ago
    18 times, 2 days ago
    26 times, 3 days ago
    279 more bugmates