# Connect to elasticsearch through java

**URL:** <https://discuss.elastic.co/t/connect-to-elasticsearch-through-java/75876>\
**Category:** Elasticsearch\
**Created:** [February 21, 2017, 12:39pm UTC](https://discuss.elastic.co/t/connect-to-elasticsearch-through-java/75876 "2017-02-21T12:39:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sujitthakalanth](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sujitthakalanth](https://discuss.elastic.co/u/sujitthakalanth)\
**Post date:** [February 21, 2017, 12:39pm UTC](https://discuss.elastic.co/t/connect-to-elasticsearch-through-java/75876/1 "2017-02-21T12:39:21Z")

</div>

Hi,  
while executing the code it is showing the error in this statement....specifiying that source not found and even not going to catch block..

try {  
client = new PreBuiltTransportClient(Settings.EMPTY)  
.addTransportAddresses(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));  
} catch (UnknownHostException e) {  
e.printStackTrace();  
}

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [February 28, 2017, 7:48pm UTC](https://discuss.elastic.co/t/connect-to-elasticsearch-through-java/75876/2 "2017-02-28T19:48:51Z")

</div>

This might be better looked at on the Elasticsearch forum. I'll move your post.

---

<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:** [March 28, 2017, 7:48pm UTC](https://discuss.elastic.co/t/connect-to-elasticsearch-through-java/75876/3 "2017-03-28T19:48:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
