File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -542,7 +542,17 @@ pub async fn run(mut opts: Opts) -> anyhow::Result<()> {
542542 let proxy_headers = opts.proxy_headers.into_iter().collect::<HeaderMap<_>>();
543543
544544 let ip_strategy = match (opts.ipv4, opts.ipv6) {
545- (false, false) => Default::default(),
545+ (false, false) => {
546+ if cfg!(target_os = "macos") && (url.host_str() == Some("localhost")) {
547+ // #784
548+ // On macOS, localhost resolves to ::1 first, So web servers that bind to localhost tend to listen ipv6 only.
549+ // So prefer ipv6 on macos for localhost.
550+
551+ hickory_resolver::config::LookupIpStrategy::Ipv6thenIpv4
552+ } else {
553+ Default::default()
554+ }
555+ }
546556 (true, false) => hickory_resolver::config::LookupIpStrategy::Ipv4Only,
547557 (false, true) => hickory_resolver::config::LookupIpStrategy::Ipv6Only,
548558 (true, true) => hickory_resolver::config::LookupIpStrategy::Ipv4AndIpv6,
You can’t perform that action at this time.
0 commit comments