I have a local development stack working well on my Mac laptop to match a production site. Everything runs at various ports on localhost:
Everything runs fine until I close the laptop. Then after opening up the laptop, the web app, which relies on Solr's Java client, cannot reach the Solr server anymore:
org.apache.solr.client.solrj.SolrServerException: No live SolrServers available to handle this request
...
Caused by: java.net.UnknownHostException: fe80: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[?:1.8.0_162]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[?:1.8.0_162]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[?:1.8.0_162]
at java.net.InetAddress.getAllByName0(InetAddress.java:1276) ~[?:1.8.0_162]
at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[?:1.8.0_162]
at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[?:1.8.0_162]
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:263) ~[httpclient-4.5.6.jar:4.5.6]
But I can still manually query the Solr server fine at localhost via curl or the web interface, even the exact same query works fine. And the connection to postgres is always fine no matter what. Just the Java client connection to solr fails.
This problem state persists through:
The only way to restore that connection is to reboot my machine. This problem has persisted across several laptops and versions of OS X over the years, but currently I'm on 10.13.6 high sierra.
My questions:
This blog post solved my problem https://thoeni.io/post/macos-sierra-java/
In essence, there seems to be a "host" of issues (couldn't let that pun go by!) around Java having a hard time resolving the local hostname in certain circumstances, and they're all solved by this easy fix:
type the hostname
command in your terminal to determine your hostname. Let's say the answer is YOUR-HOSTNAME.
add or modify these entries in your /etc/hosts
:
127.0.0.1 localhost YOUR-HOSTNAME ::1 localhost YOUR-HOSTNAME
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.