{"record":{"id":"6837328522e4e01f","repo":"cilium/cilium","slug":"failed-to-get-host-device-s","errorCode":null,"errorMessage":"failed to get host device %s","messagePattern":"failed to get host device (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proxy/routes.go","lineNumber":65,"sourceCode":"\n\tfromIngressProxy, fromEgressProxy, mtu := requireFromProxyRoutes(ipsecEnabled, wireguardEnabled, mtu)\n\n\trxn := p.db.ReadTxn()\n\thostDevice, _, hostDeviceFound := p.devices.Get(rxn, tables.DeviceByName(defaults.HostDevice))\n\tciliumNetDevice, _, ciliumNetDeviceFound := p.devices.Get(rxn, tables.DeviceByName(defaults.SecondHostDevice))\n\tlo, _, loFound := p.devices.Get(rxn, tables.DeviceByName(\"lo\"))\n\n\tif option.Config.EnableIPv4 && p.enabled {\n\t\tif !loFound {\n\t\t\treturn fmt.Errorf(\"failed to get loopback device\")\n\t\t}\n\t\tif err := installToProxyRoutesIPv4(lo, p.routeManager, p.routeOwner); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif fromIngressProxy || fromEgressProxy {\n\t\t\tif !hostDeviceFound {\n\t\t\t\treturn fmt.Errorf(\"failed to get host device %s\", defaults.HostDevice)\n\t\t\t}\n\t\t\tinternalIP, _ := netipx.FromStdIP(localNode.GetCiliumInternalIP(false))\n\t\t\tif err := installFromProxyRoutesIPv4(p.routeManager, p.routeOwner, internalIP, hostDevice, fromIngressProxy, fromEgressProxy, mtu); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tif err := removeFromProxyRulesIPv4(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif err := removeToProxyRulesIPv4(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := removeFromProxyRulesIPv4(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/proxy/routes.go#L47-L83","documentation":"When routing from-proxy routes are required (native routing with Envoy L7 proxy, IPSec, or WireGuard) and IPv4 is enabled, ReinstallRoutingRules requires the host device (defaults.HostDevice, e.g. cilium_host) from the device table. If that lookup fails it returns this error because the from-proxy default route and link route need the host device as their output device.","triggerScenarios":"Calling ReinstallRoutingRules with EnableIPv4=true, proxy enabled, and fromIngressProxy/fromEgressProxy true (EnableEnvoyConfig, ipsecEnabled, or wireguardEnabled) while p.devices has no entry for defaults.HostDevice.","commonSituations":"cilium_host interface not yet created during early agent startup; node initialization failure left the host device unregistered; environment where the cilium_host link was deleted manually; device table not synced with netlink.","solutions":["Ensure node initialization has completed so cilium_host exists and is registered in the devices table before ReinstallRoutingRules runs.","Verify `ip link show cilium_host` succeeds on the node; if missing, restart the agent to recreate it.","Retry the reinitialize loop — the device is typically registered shortly after startup.","Check that no custom device filtering excludes cilium_host from the devices table."],"exampleFix":"// before\nif !hostDeviceFound {\n    return fmt.Errorf(\"failed to get host device %s\", defaults.HostDevice)\n}\n// after\n// retry with backoff until the device table contains cilium_host\nhostDevice, _, hostDeviceFound := p.devices.Get(rxn, tables.DeviceByName(defaults.HostDevice))\nif !hostDeviceFound {\n    return retry.NewError(ctx, true, fmt.Errorf(\"failed to get host device %s\", defaults.HostDevice))\n}","handlingStrategy":"retry","validationCode":"rxn := p.db.ReadTxn()\nif _, _, ok := p.devices.Get(rxn, tables.DeviceByName(defaults.HostDevice)); !ok {\n    return fmt.Errorf(\"host device %s not registered yet\", defaults.HostDevice)\n}","typeGuard":"func hostDeviceReady(devs deviceCache) bool {\n    _, _, ok := devs.Get(devs.ReadTxn(), tables.DeviceByName(defaults.HostDevice))\n    return ok\n}","tryCatchPattern":"if err := p.ReinstallRoutingRules(ctx, mtu, ipsec, wg); err != nil {\n    if strings.Contains(err.Error(), \"failed to get host device\") {\n        return retry.NewError(ctx, true, err) // retriable until cilium_host exists\n    }\n    return err\n}","preventionTips":["Ensure node initialization (cilium_host creation) completes before routing-rule reinstall","Check `ip link show cilium_host` when diagnosing","Use retry-with-backoff for device lookups during startup","Avoid manually deleting cilium_host on live nodes"],"tags":["network","linux","routing","cilium"],"backgroundTag":"device-not-found","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}