org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Con nection refused

Spring JIRA | Kaan Yamanyar | 6 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    It is not necessary that rabbit mq servers are running while the consumer application is being started. If connection is not possible, it should postpone it later on, for example 5 minutes later. Error creating bean with name 'org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer#0' defined in class path resou rce [com/yamanyar/def/publisher/spring-def-core.xml]: Invocation of init method failed; nested exception is org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Con nection refused at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) ... Caused by: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused at org.springframework.amqp.rabbit.support.RabbitUtils.convertRabbitAccessException(RabbitUtils.java:111) at org.springframework.amqp.rabbit.support.RabbitAccessor.convertRabbitAccessException(RabbitAccessor.java:135) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.initialize(AbstractRabbitListeningContainer.java:137) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.afterPropertiesSet(AbstractRabbitListeningContainer.java:99) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.afterPropertiesSet(SimpleMessageListenerContainer.java:143) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 36 more Caused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at com.rabbitmq.client.ConnectionFactory.createFrameHandler(ConnectionFactory.java:338) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:376) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:399) at org.springframework.amqp.rabbit.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:198) at org.springframework.amqp.rabbit.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:144) at org.springframework.amqp.rabbit.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:133) at org.springframework.amqp.rabbit.support.RabbitAccessor.createConnection(RabbitAccessor.java:89) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.createSharedConnection(AbstractRabbitListeningContainer.java:312) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.establishSharedConnection(AbstractRabbitListeningContainer.java:286) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doInitialize(SimpleMessageListenerContainer.java:181) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.initialize(AbstractRabbitListeningContainer.java:132) ... 40 more

    Spring JIRA | 6 years ago | Kaan Yamanyar
    org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Con nection refused
  2. 0

    It is not necessary that rabbit mq servers are running while the consumer application is being started. If connection is not possible, it should postpone it later on, for example 5 minutes later. Error creating bean with name 'org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer#0' defined in class path resou rce [com/yamanyar/def/publisher/spring-def-core.xml]: Invocation of init method failed; nested exception is org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Con nection refused at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) ... Caused by: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused at org.springframework.amqp.rabbit.support.RabbitUtils.convertRabbitAccessException(RabbitUtils.java:111) at org.springframework.amqp.rabbit.support.RabbitAccessor.convertRabbitAccessException(RabbitAccessor.java:135) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.initialize(AbstractRabbitListeningContainer.java:137) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.afterPropertiesSet(AbstractRabbitListeningContainer.java:99) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.afterPropertiesSet(SimpleMessageListenerContainer.java:143) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 36 more Caused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at com.rabbitmq.client.ConnectionFactory.createFrameHandler(ConnectionFactory.java:338) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:376) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:399) at org.springframework.amqp.rabbit.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:198) at org.springframework.amqp.rabbit.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:144) at org.springframework.amqp.rabbit.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:133) at org.springframework.amqp.rabbit.support.RabbitAccessor.createConnection(RabbitAccessor.java:89) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.createSharedConnection(AbstractRabbitListeningContainer.java:312) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.establishSharedConnection(AbstractRabbitListeningContainer.java:286) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doInitialize(SimpleMessageListenerContainer.java:181) at org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer.initialize(AbstractRabbitListeningContainer.java:132) ... 40 more

    Spring JIRA | 6 years ago | Kaan Yamanyar
    org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Con nection refused

    Root Cause Analysis

    1. org.springframework.amqp.AmqpConnectException

      java.net.ConnectException: Con nection refused

      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean()
    2. Spring Beans
      AbstractBeanFactory.getBean
      1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
      2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      3. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      4. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
      5. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      6. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
      7. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      7 frames