{"record":{"id":"df85f55809d11495","repo":"juicedata/juicefs","slug":"are-you-connected-to-the-network","errorCode":null,"errorMessage":"are you connected to the network?","messagePattern":"are you connected to the network\\?","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/java/libjfs/main.go","lineNumber":2120,"sourceCode":"\t\t\tcase *net.IPNet:\n\t\t\t\tip = v.IP\n\t\t\tcase *net.IPAddr:\n\t\t\t\tip = v.IP\n\t\t\t}\n\t\t\tif ip == nil || ip.IsLoopback() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tip = ip.To4()\n\t\t\tif ip == nil {\n\t\t\t\tcontinue // not an ipv4 address\n\t\t\t}\n\t\t\tif !strings.HasPrefix(ip.String(), mask) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn ip.String(), nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"are you connected to the network?\")\n}\n\n//export jfs_get_token\nfunc jfs_get_token(h int64, cname *C.char, buf uintptr, count int32, renewer *C.char) int32 {\n\tw := F(h)\n\tif w == nil {\n\t\treturn EINVAL\n\t}\n\tid, t, eno := kerb.issue(w.ctx, w.Meta(), C.GoString(cname), w.user, C.GoString(renewer))\n\tif eno != 0 {\n\t\tlogger.Errorf(\"get token for %s: %s\", w.volname, eno)\n\t\treturn errno(eno)\n\t}\n\twb := utils.NewNativeBuffer(toBuf(buf, count))\n\twb.Put32(id)\n\twb.Put64(uint64(t.Issued))\n\twb.Put64(uint64(t.Expire))\n\twb.Put([]byte(t.Password))","sourceCodeStart":2102,"sourceCodeEnd":2138,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/libjfs/main.go#L2102-L2138","documentation":"The libjfs local IP discovery helper enumerates the host's network interfaces looking for an address matching a given mask, and returns \"are you connected to the network?\" when no usable address is found — i.e. no interface has an IP matching the mask (or no non-loopback IP exists at all).","triggerScenarios":"Calling the IP-lookup function on a host whose interfaces are all down or loopback-only; an interface whose IP does not match the supplied subnet mask; running inside a network namespace/container with no configured interfaces; IPv6-only environments where the mask comparison against IPv4 strings never matches.","commonSituations":"Containers or VMs started before the network is up, hosts with only a loopback device, sandboxed CI runners without network configuration, or a wrong subnet mask passed that matches no interface.","solutions":["Verify the host has an up, non-loopback interface with an IP address (ip addr / ifconfig).","Check the mask/prefix argument actually matches one of the host's subnets.","Ensure containers have networking configured (docker run --network, CNI setup) before the lookup runs.","If interfaces come up asynchronously, retry the lookup after a short delay."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"func hasUsableIP() bool {\n\tifaces, err := net.Interfaces()\n\tif err != nil { return false }\n\tfor _, i := range ifaces {\n\t\tif i.Flags&net.FlagUp == 0 || i.Flags&net.FlagLoopback != 0 { continue }\n\t\taddrs, _ := i.Addrs()\n\t\tif len(addrs) > 0 { return true }\n\t}\n\treturn false\n}","typeGuard":null,"tryCatchPattern":"ip, err := localIP(mask)\nif err != nil {\n\tlog.Printf(\"no matching local IP for mask %s: %v; retrying\", mask, err)\n\ttime.Sleep(time.Second)\n\tip, err = localIP(mask)\n}","preventionTips":["Wait for network readiness (interface up) before IP discovery in containers/VMs","Pass a mask that matches an actual host subnet; verify with `ip addr`","Avoid running IP-dependent code in loopback-only namespaces","Log all interface addresses when lookup fails to ease diagnosis"],"tags":["network","java-sdk","ip-address"],"backgroundTag":"network-unavailable","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}