diff --git a/src/HTTP.jl b/src/HTTP.jl index b997162f..cbbf1be7 100644 --- a/src/HTTP.jl +++ b/src/HTTP.jl @@ -633,7 +633,14 @@ end # only run if precompiling if VERSION >= v"1.9.0-0" && ccall(:jl_generating_output, Cint, ()) == 1 - include("precompile.jl") + do_precompile = true + try + Sockets.getalladdrinfo("localhost") + catch ex + @debug "Skipping precompilation workload because localhost cannot be resolved. Check firewall settings" exception=(ex,catch_backtrace()) + do_precompile = false + end + do_precompile && include("precompile.jl") end end # module diff --git a/src/precompile.jl b/src/precompile.jl index e104f736..4f38869f 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -26,11 +26,11 @@ try # listenany allows changing port if that one is already in use, so check the actual port _port = HTTP.port(server) url = "https://localhost:$_port" - + env = ["JULIA_NO_VERIFY_HOSTS" => "localhost", "JULIA_SSL_NO_VERIFY_HOSTS" => nothing, "JULIA_ALWAYS_VERIFY_HOSTS" => nothing] - + withenv(env...) do @compile_workload begin HTTP.get(url);