{"record":{"id":"314d7422e4810c9f","repo":"slimtoolkit/slim","slug":"dialing-backend-v","errorCode":null,"errorMessage":"dialing backend: %v","messagePattern":"dialing backend: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/probe/http/internal/fastcgi.go","lineNumber":91,"sourceCode":"\n\tenv, err := t.buildEnv(r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building environment: %v\", err)\n\t}\n\n\tnetwork, address := \"tcp\", r.URL.Host\n\n\tif log.IsLevelEnabled(log.DebugLevel) {\n\t\tenvJSON, _ := json.Marshal(env)\n\t\tlog.Debugf(\"HTTP probe - FastCGI env - %s\", string(envJSON))\n\t}\n\n\tctx := r.Context()\n\tdialer := net.Dialer{Timeout: t.DialTimeout}\n\tfcgiBackend, err := DialWithDialerContext(ctx, network, address, dialer)\n\tif err != nil {\n\t\t// TODO: wrap in a special error type if the dial failed, so retries can happen if enabled\n\t\treturn nil, fmt.Errorf(\"dialing backend: %v\", err)\n\t}\n\t// fcgiBackend gets closed when response body is closed (see clientCloser)\n\n\t// read/write timeouts\n\tif err := fcgiBackend.SetReadTimeout(t.ReadTimeout); err != nil {\n\t\treturn nil, fmt.Errorf(\"setting read timeout: %v\", err)\n\t}\n\tif err := fcgiBackend.SetWriteTimeout(t.WriteTimeout); err != nil {\n\t\treturn nil, fmt.Errorf(\"setting write timeout: %v\", err)\n\t}\n\n\tcontentLength := r.ContentLength\n\tif contentLength == 0 {\n\t\tcontentLength, _ = strconv.ParseInt(r.Header.Get(\"Content-Length\"), 10, 64)\n\t}\n\n\tvar resp *http.Response\n\tswitch r.Method {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/probe/http/internal/fastcgi.go#L73-L109","documentation":"After building the FastCGI environment, RoundTrip dials the FastCGI backend at network/address (defaulting to tcp + r.URL.Host) with the configured dial timeout. A dial failure is wrapped as \"dialing backend: %v\". This is the classic 'cannot reach the FastCGI process' failure and is explicitly marked as a candidate for retry.","triggerScenarios":"RoundTrip when DialWithDialerContext fails: backend not listening on r.URL.Host's port, wrong network type (unix vs tcp), connection refused/timeout, or context cancellation before the dial completes.","commonSituations":"Probing a containerized PHP app whose php-fpm listens on a unix socket but the transport dials tcp; wrong port in the probe URL; app not yet started when the probe runs; firewall or NetworkPolicy blocking the connection.","solutions":["Verify the backend address/port in the probe URL matches what the FastCGI server listens on (netstat/php-fpm config).","If the backend uses a unix socket, configure the transport to dial unix instead of tcp.","Increase DialTimeout and/or add retry logic — the code comments dial failures as retryable.","Confirm the app process is running before probing (start ordering / readiness probes)."],"exampleFix":"// before: probing tcp while php-fpm listens on a socket\n// after: point the transport at the socket\nt := FastCGITransport{ /* network: \"unix\", address: \"/run/php-fpm.sock\", DialTimeout: 5 * time.Second */ }","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", host+\":\"+port, 3*time.Second)\nif err != nil {\n    return fmt.Errorf(\"FastCGI backend unreachable at %s:%s — start it first\", host, port)\n}\nconn.Close()","typeGuard":null,"tryCatchPattern":"var resp *http.Response\nerr := retry(3, backoff, func() error {\n    var e error\n    resp, e = fcgiTransport.RoundTrip(req)\n    if e != nil && strings.Contains(e.Error(), \"dialing backend\") {\n        return e // retryable per transport comments\n    }\n    return e\n})","preventionTips":["Confirm the FastCGI listen address/port (php-fpm pool config) matches the probe URL.","Use unix-socket transport config when the backend listens on a socket.","Wait for app readiness before probing; add retry with backoff for dial errors.","Set a reasonable DialTimeout (a few seconds) on the transport."],"tags":["fastcgi","connection","http-probe"],"backgroundTag":"connection-refused","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}