# Unable to catch exception - org.elasticsearch.transport.ConnectTransportException

**URL:** <https://discuss.elastic.co/t/unable-to-catch-exception-org-elasticsearch-transport-connecttransportexception/12572>\
**Category:** Elasticsearch\
**Created:** [June 28, 2013, 4:06am UTC](https://discuss.elastic.co/t/unable-to-catch-exception-org-elasticsearch-transport-connecttransportexception/12572 "2013-06-28T04:06:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashwini\_harshe](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@ashwini\_harshe](https://discuss.elastic.co/u/ashwini_harshe)\
**Post date:** [June 28, 2013, 4:06am UTC](https://discuss.elastic.co/t/unable-to-catch-exception-org-elasticsearch-transport-connecttransportexception/12572/1 "2013-06-28T04:06:19Z")

</div>

Hi,

I am using elasticsearc 0.91.1 and I am unable to catch exception org.elasticsearch.transport.ConnectTransportException while connecting to elasticsearch using TransportClient().  
Below is my code snippet:  
try {

Settings settings = ImmutableSettings.settingsBuilder().put("client.transport.sniff", true).build();  
logger.debug("hostname="+targetConnections.getHostname()+",port="+targetConnections.getPort());

this.client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(  
targetConnections.getHostname(), Integer.parseInt(targetConnections.getPort())));

}catch(ElasticSearchException e) {  
logger.debug(" **_Elasticsearchexception_** \*\*");  
}  
catch(Exception e) {  
logger.debug("Exception="+e.getMessage());  
}  
logger.debug("Client connected to ES!!!");

On console I get following exception:

27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [generic], type [cached], keep\_alive [30s]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [index], type [fixed], size [8], queue\_size [null], reject\_policy [abort], queue\_type [linked]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [bulk], type [fixed], size [8], queue\_size [null], reject\_policy [abort], queue\_type [linked]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [get], type [fixed], size [8], queue\_size [null], reject\_policy [abort], queue\_type [linked]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [search], type [fixed], size [24], queue\_size [1k], reject\_policy [abort], queue\_type [linked]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [percolate], type [fixed], size [8], queue\_size [null], reject\_policy [abort], queue\_type [linked]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [management], type [scaling], min [1], size [5], keep\_alive [5m]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [flush], type [scaling], min [1], size [4], keep\_alive [5m]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [merge], type [scaling], min [1], size [4], keep\_alive [5m]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [refresh], type [scaling], min [1], size [4], keep\_alive [5m]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [warmer], type [scaling], min [1], size [4], keep\_alive [5m]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] creating thread\_pool [snapshot], type [scaling], min [1], size [4], keep\_alive [5m]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] using worker\_count[16], port[9300-9400], bind\_host[null], publish\_host[null], compress[false], connect\_timeout[30s], connections\_per\_node[2/6/1], receive\_predictor[512kb-\>512kb]  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] node\_sampler\_interval[5s]  
27 Jun 2013 20:55:53 DEBUG [elasticsearch[Hijacker][transport\_client\_worker][T#1]{New I/O worker #1}] - Using select timeout of 500  
27 Jun 2013 20:55:53 DEBUG [elasticsearch[Hijacker][transport\_client\_worker][T#1]{New I/O worker #1}] - Epoll-bug workaround enabled = false  
27 Jun 2013 20:55:53 DEBUG [main] - [Hijacker] adding address [[#transport#-1][inet[localhost/127.0.0.1:9300]]]  
27 Jun 2013 20:55:54 DEBUG [elasticsearch[Hijacker][management][T#1]] - [Hijacker] failed to connect to node [[#transport#-1][inet[localhost/127.0.0.1:9300]]], ignoring...  
org.elasticsearch.transport.ConnectTransportException: [][inet[localhost/127.0.0.1:9300]] connect\_timeout[30s]  
at org.elasticsearch.transport.netty.NettyTransport.connectToChannelsLight(NettyTransport.java:644)  
at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:606)  
at org.elasticsearch.transport.netty.NettyTransport.connectToNodeLight(NettyTransport.java:575)  
at org.elasticsearch.transport.TransportService.connectToNodeLight(TransportService.java:131)  
at org.elasticsearch.client.transport.TransportClientNodesService$SniffNodesSampler$1.run(TransportClientNodesService.java:367)  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:662)  
Caused by: java.net.ConnectException: Connection refused: no further information: localhost/127.0.0.1:9300  
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)  
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)  
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)  
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)  
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)  
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)  
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)  
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
... 3 more  
27 Jun 2013 20:55:54 DEBUG [main] - Client connected to ES!!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:29am UTC](https://discuss.elastic.co/t/unable-to-catch-exception-org-elasticsearch-transport-connecttransportexception/12572/2 "2017-07-06T02:29:07Z")

</div>


