# How do I fix "java.net.BindException: Can't assign requested address"?

**URL:** <https://discuss.hail.is/t/how-do-i-fix-java-net-bindexception-cant-assign-requested-address/115>\
**Category:** Development\
**Created:** [February 6, 2017, 8:57pm UTC](https://discuss.hail.is/t/how-do-i-fix-java-net-bindexception-cant-assign-requested-address/115 "2017-02-06T20:57:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [February 6, 2017, 8:57pm UTC](https://discuss.hail.is/t/how-do-i-fix-java-net-bindexception-cant-assign-requested-address/115/1 "2017-02-06T20:57:25Z")

</div>

The full message looks like:

```nohighlight
Exception in thread "main" java.net.BindException: Can't assign requested address: Service 'sparkDriver' failed after 16 retries!
Consider explicitly setting the appropriate port for the service 'sparkDriver' (for example spark.ui.port for SparkUI) to an available port or increasing spark.port.maxRetries.

```

---

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [February 6, 2017, 8:58pm UTC](https://discuss.hail.is/t/how-do-i-fix-java-net-bindexception-cant-assign-requested-address/115/2 "2017-02-06T20:58:44Z")

</div>

This error is often caused by running spark on a machine connected to a VPN or a personal wi-fi hotspot (i.e. tethering to a phone). First, try fixing it by editing your hosts file as suggested in [this StackOverflow post](http://stackoverflow.com/a/35852781/6823256). If that fails, try running `hail` while disconnected from any VPN or personal wi-fi hotspot.

---

<div class="post-metadata">

**Author:** ![shubham](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shubham](https://discuss.hail.is/u/shubham)\
**Post date:** [November 12, 2018, 6:42pm UTC](https://discuss.hail.is/t/how-do-i-fix-java-net-bindexception-cant-assign-requested-address/115/3 "2018-11-12T18:42:15Z")

</div>

This worked for me:

**sudo hostname -s 127.0.0.1**

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [November 12, 2018, 7:32pm UTC](https://discuss.hail.is/t/how-do-i-fix-java-net-bindexception-cant-assign-requested-address/115/4 "2018-11-12T19:32:31Z")

</div>

I’d note that the above is not a recommended solution – there are ways around this without changing the hostname.

---

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [December 4, 2020, 7:52pm UTC](https://discuss.hail.is/t/how-do-i-fix-java-net-bindexception-cant-assign-requested-address/115/5 "2020-12-04T19:52:28Z")

</div>

First try this:

```auto
sudo /bin/sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hostname"

```

Now try to use Hail. If Hail gives the same error, try this:

```auto
echo 'export PYSPARK_SUBMIT_ARGS='\''--driver-memory 16g --executor-memory 16g --conf "spark.driver.bindAddress=127.0.0.1" pyspark-shell'\' >> ~/.$(basename ${SHELL})rc

```

Now try Hail again. If it still fails, respond to this thread.
