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


#1

The full message looks like:

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.

#2

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. If that fails, try running hail while disconnected from any VPN or personal wi-fi hotspot.


#3

This worked for me:

sudo hostname -s 127.0.0.1


#4

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