# Failure starting elasticsearch server and java client on same FreeBSD machine

**URL:** <https://discuss.elastic.co/t/failure-starting-elasticsearch-server-and-java-client-on-same-freebsd-machine/5228>\
**Category:** Elasticsearch\
**Created:** [August 23, 2011, 5:54pm UTC](https://discuss.elastic.co/t/failure-starting-elasticsearch-server-and-java-client-on-same-freebsd-machine/5228 "2011-08-23T17:54:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Delpha](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Andrew\_Delpha](https://discuss.elastic.co/u/Andrew_Delpha)\
**Post date:** [August 23, 2011, 5:54pm UTC](https://discuss.elastic.co/t/failure-starting-elasticsearch-server-and-java-client-on-same-freebsd-machine/5228/1 "2011-08-23T17:54:35Z")

</div>

I've successfully have elasticsearch running on my Linux dev box which is  
Elastic search server running in it's own process  
Tomcat server running a webapp that connects to the cluster as a client  
(node.data=false)

I ran into a problem when I tried to deploy our app in this configuration to  
our test server (FreeBSD 7.3) though. Basically whichever server starts  
last gets a - DiscoveryException[Failed to setup multicast  
socket] BindException[Address already in use]  
(I only tried starting tomcat first to see if the elasticsearch server would  
have the same issue, which it does and the client in Tomcat eventually times  
out because it can't find a master).

Here's the relevant part of the stack trace I get in the client running in  
tomcat when tomcat is started last:  
Caused by: org.elasticsearch.discovery.DiscoveryException: Failed to setup  
multicast socket  
at  
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing.doStart(MulticastZenPing.java:174)  
at  
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:80)  
at  
org.elasticsearch.discovery.zen.ping.ZenPingService.doStart(ZenPingService.java:92)  
at  
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:80)  
at  
org.elasticsearch.discovery.zen.ZenDiscovery.doStart(ZenDiscovery.java:146)  
at  
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:80)  
at  
org.elasticsearch.discovery.DiscoveryService.doStart(DiscoveryService.java:59)  
at  
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:80)  
at  
org.elasticsearch.node.internal.InternalNode.start(InternalNode.java:184)  
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)  
at  
org.projectx.elasticsearch.ElasticsearchNodeFactoryBean.internalCreateNode(ElasticsearchNodeFactoryBean.java:86)  
at  
org.projectx.elasticsearch.ElasticsearchNodeFactoryBean.afterPropertiesSet(ElasticsearchNodeFactoryBean.java:66)  
at  
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)  
at  
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)  
... 49 more  
Caused by: java.net.BindException: Address already in use  
at java.net.PlainDatagramSocketImpl.bind0(Native Method)  
at  
java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)  
at java.net.DatagramSocket.bind(DatagramSocket.java:368)  
at java.net.MulticastSocket.(MulticastSocket.java:147)  
at java.net.MulticastSocket.(MulticastSocket.java:112)  
at  
org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing.doStart(MulticastZenPing.java:158)  
... 62 more

Elasticsearch version 0.17.6

> uname -prs  
> FreeBSD 7.3-RELEASE amd64  
> java -version  
> java version "1.6.0\_07"  
> Diablo Java(TM) SE Runtime Environment (build 1.6.0\_07-b02)  
> Diablo Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)

I'd done some google searching. Didn't find anything recent, but I did find  
an old discussion about some issues with how BSD had different socket  
options from Linux and issues with how java chose them -  
[http://freebsd.1045724.n5.nabble.com/SO-REUSEADDR-should-not-also-mean-SO-REUSEPORT-td4188641.html](http://freebsd.1045724.n5.nabble.com/SO-REUSEADDR-should-not-also-mean-SO-REUSEPORT-td4188641.html)

Any ideas what might be going on? Anyone else ever hit this? I'm going to  
look into switching to unicast discovery, but wanted to document and see if  
anyone had any ideas what was going on here.

Thanks,  
--Andy

---

<div class="post-metadata">

**Author:** ![Andrew\_Delpha](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Andrew\_Delpha](https://discuss.elastic.co/u/Andrew_Delpha)\
**Post date:** [August 23, 2011, 7:18pm UTC](https://discuss.elastic.co/t/failure-starting-elasticsearch-server-and-java-client-on-same-freebsd-machine/5228/2 "2011-08-23T19:18:35Z")

</div>

Forgot to say that the elasticsearch server configuration was the default  
config file with just a change to the cluster name. The client node running  
in tomcat was configured with that cluster name and node.data=false,  
node.client=true, and node.local=false.

Also, I've been able to successfully deploy on our test server now with  
unicast discovery, so this isn't a critical issue for me now.

Thanks for this great tool!

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 24, 2011, 6:25pm UTC](https://discuss.elastic.co/t/failure-starting-elasticsearch-server-and-java-client-on-same-freebsd-machine/5228/3 "2011-08-24T18:25:40Z")

</div>

Strange multicast failure, never seen that one... . In theory, we should not  
get it, Will try and dig around to see why it happens..

On Tue, Aug 23, 2011 at 10:18 PM, Andrew Delpha [andrew.delpha@gmail.com](mailto:andrew.delpha@gmail.com)wrote:

> Forgot to say that the elasticsearch server configuration was the default  
> config file with just a change to the cluster name. The client node running  
> in tomcat was configured with that cluster name and node.data=false,  
> node.client=true, and node.local=false.
> 
> Also, I've been able to successfully deploy on our test server now with  
> unicast discovery, so this isn't a critical issue for me now.
> 
> Thanks for this great tool!

---

<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, 3:56am UTC](https://discuss.elastic.co/t/failure-starting-elasticsearch-server-and-java-client-on-same-freebsd-machine/5228/4 "2017-07-06T03:56:08Z")

</div>


