{"record":{"id":"a7819099ce2bba98","repo":"openfaas/faas","slug":"log-request-failed","errorCode":null,"errorMessage":"log request failed","messagePattern":"log request failed","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"gateway/handlers/logs.go","lineNumber":65,"sourceCode":"\t\twf, ok := w.(writerFlusher)\n\t\tif !ok {\n\t\t\tlog.Println(\"LogHandler: response is not a Flusher, required for streaming response\")\n\t\t\thttp.NotFound(w, r)\n\t\t\treturn\n\t\t}\n\n\t\tif writeRequestURI {\n\t\t\tlog.Printf(\"LogProxy: proxying request to %s %s\\n\", logRequest.Host, logRequest.URL.String())\n\t\t}\n\n\t\tctx, cancel := context.WithCancel(ctx)\n\t\tlogRequest = logRequest.WithContext(ctx)\n\t\tdefer cancel()\n\n\t\tlogResp, err := http.DefaultTransport.RoundTrip(logRequest)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"LogProxy: forwarding request failed: %s\\n\", err.Error())\n\t\t\thttp.Error(w, \"log request failed\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tdefer logResp.Body.Close()\n\n\t\tswitch logResp.StatusCode {\n\t\tcase http.StatusNotFound, http.StatusNotImplemented:\n\t\t\tw.WriteHeader(http.StatusNotImplemented)\n\t\t\treturn\n\t\tcase http.StatusOK:\n\t\t\t// watch for connection closures and stream data\n\t\t\t// connections and contexts should have cancel methods deferred already\n\t\t\tselect {\n\t\t\tcase err := <-copyNotify(&unbufferedWriter{wf}, logResp.Body):\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"LogProxy: error while copy: %s\", err.Error())\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\tcase <-cn.CloseNotify():","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/openfaas/faas/blob/8d803bf9e2655aec6a60fd0e25b392839f96af95/gateway/handlers/logs.go#L47-L83","documentation":"The log streaming proxy in gateway/handlers/logs.go forwards the client's log request to the function provider's /system/logs endpoint using http.DefaultTransport.RoundTrip. If that round trip fails at the transport level — connection refused, DNS failure, TLS error, timeout — the gateway logs 'LogProxy: forwarding request failed' and returns 500 with 'log request failed'. The provider address comes from the gateway's URL resolver, typically the functions_provider_url/upstream configuration.","triggerScenarios":"Calling GET /system/logs?name=myfn&follow=true while the provider (faas-netes, faasd, or another faas-provider implementation) cannot be reached: wrong upstream host or port, provider pod not running or not ready, NetworkPolicy blocking gateway-to-provider traffic, or a TLS certificate mismatch on the upstream.","commonSituations":"functions_provider_url pointing at a stale ClusterIP or wrong port after a reinstall; provider crash-looping; CNI/NetworkPolicy changes blocking namespace-local traffic; faasd address or socket changed.","solutions":["From inside the gateway container, verify the provider answers: curl the provider /healthz or /system/functions endpoint","Correct functions_provider_url so it points directly at the provider service","Check the provider pod status and logs (kubectl get pods -n openfaas, kubectl logs on the provider deployment)","Review NetworkPolicies or service mesh rules between gateway and provider namespaces","If DNS fails, confirm the provider service exists and the namespace suffix is correct"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# preflight: provider reachable before streaming logs\ncurl -fsS \"$FUNCTIONS_PROVIDER_URL/healthz\" || echo 'provider unreachable: log streaming will fail'","typeGuard":null,"tryCatchPattern":"resp, err := client.Get(logsURL)\nif err != nil || resp.StatusCode == http.StatusInternalServerError {\n    // transport failure to the provider: back off and retry\n    time.Sleep(backoff)\n    continue\n}","preventionTips":["Health-check the provider before opening log streams","Keep functions_provider_url pinned to a stable service DNS name","Alert on the gateway log line 'LogProxy: forwarding request failed' to catch provider outages early"],"tags":["network","http","logging","provider","kubernetes"],"backgroundTag":null,"analyzedSha":"8d803bf9e2655aec6a60fd0e25b392839f96af95","analyzedAt":"2026-08-16T00:12:29.759Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}