简体   繁体   中英

Socket connect exception saying connection refused

I am building a spring boot application, which has multiple micro-services which are being used by one main service. Services are created as maven modules and I am using intelliJ IDEA 15 with trial period. Now when I am trying to run the service I am getting the following error. I think my tomcat server is not running but I am not getting how to check and if this is the problem then how to resolve. I have included tomcat dependency in pom.xml .

the class which I am running is this->

AlpsWsApplication.java

@SpringBootApplication
public class AlpsWsApplication {
    private static final Logger logger = LoggerFactory
            .getLogger(AlpsWsApplication.class);
    public static void main(String[] args) {
        SpringApplication.run(AlpsWsApplication.class, args);
    }
}

with this there are hibernate, Apache qpid configuration files.

Stack trace:

ERROR 10 Mar 2016 14:01:10,185 [main] org.springframework.boot.SpringApplication: Application startup failed
com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused
    at com.ecwid.consul.transport.DefaultHttpTransport.executeRequest(DefaultHttpTransport.java:87)
    at com.ecwid.consul.transport.DefaultHttpTransport.makeGetRequest(DefaultHttpTransport.java:46)
    at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:66)
    at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:135)
    at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:128)
    at com.ecwid.consul.v1.ConsulClient.getKVValues(ConsulClient.java:346)
    at org.springframework.cloud.consul.config.ConsulPropertySource.init(ConsulPropertySource.java:57)
    at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locate(ConsulPropertySourceLocator.java:70)
    at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:88)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:628)
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:328)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101)
    at com.alps.AlpsWsApplication.main(AlpsWsApplication.java:13)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
    at com.ecwid.consul.transport.DefaultHttpTransport.executeRequest(DefaultHttpTransport.java:71)
    ... 14 more

'Connection refused' has exactly one meaning: the target host was up and there was nothing listening at the specified port. So either you didn't start the service or you got the IP address or port wrong.

And specifically contrary to the comments here:

  • it is not a 'host down' condition
  • it is not a firewall problem
  • it is not a network connectivity problem (ping).

问题是我在 pom.xml 文件中包含了 spring cloud consul 依赖项,但没有启动服务器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM