{"record":{"id":"39d9506d975e762c","repo":"shadow1ng/fscan","slug":"i18n-gettext-memcached-connect-failed","errorCode":null,"errorMessage":"i18n.GetText(\"memcached_connect_failed\")","messagePattern":"i18n\\.GetText\\(\"memcached_connect_failed\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/memcached.go","lineNumber":124,"sourceCode":"\tresponse := make([]byte, 1024)\n\tn, err := conn.Read(response)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tresponseStr := string(response[:n])\n\treturn common.ContainsAny(responseStr, \"VERSION\", \"memcached\")\n}\n\nfunc (p *MemcachedPlugin) identifyService(ctx context.Context, info *common.HostInfo, session *common.ScanSession) *ScanResult {\n\ttarget := info.Target()\n\n\tconn := p.connectToMemcached(ctx, info, session)\n\tif conn == nil {\n\t\treturn &ScanResult{\n\t\t\tSuccess: false,\n\t\t\tService: \"memcached\",\n\t\t\tError:   fmt.Errorf(\"%s\", i18n.GetText(\"memcached_connect_failed\")),\n\t\t}\n\t}\n\tdefer func() { _ = conn.Close() }()\n\n\tif p.testBasicCommand(conn, session.Config) {\n\t\tbanner := \"Memcached\"\n\t\tsession.LogSuccess(i18n.Tr(\"memcached_service\", target, banner))\n\t\treturn &ScanResult{\n\t\t\tType:    plugins.ResultTypeService,\n\t\t\tSuccess: true,\n\t\t\tService: \"memcached\",\n\t\t\tBanner:  banner,\n\t\t}\n\t}\n\n\treturn &ScanResult{\n\t\tSuccess: false,\n\t\tService: \"memcached\",","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/memcached.go#L106-L142","documentation":"identifyService returns this error when the initial TCP dial to the memcached target fails inside connectToMemcached (dial error or context cancellation). The plugin could not even open a socket, so it reports 'memcached connect failed' instead of a service-identification failure. It surfaces in DisableBrute mode or whenever identifyService runs via Scan.","triggerScenarios":"Running the memcached plugin (ports 11211-11213) against a host where: the port is closed/filtered; DNS or IP routing fails; ModuleTimeout expires during DialTCP; the parent context is cancelled before the dial completes.","commonSituations":"Scanning hosts behind a firewall that drops (rather than rejects) packets, causing timeouts; typo'd targets or stale IP lists; scanning through NAT where 11211 is not forwarded; rate-limiting by the target network.","solutions":["Confirm the port is open: nc -zv <host> 11211 from the scanning machine.","Check for firewalls/iptables/security groups blocking the scanner's source IP.","Raise ModuleTimeout in the scan config for high-latency networks.","Verify the target address format (host:port) in HostInfo is correct and reachable.","Re-run with retries; transient packet loss can fail a single dial attempt."],"exampleFix":"// before\nconn := p.connectToMemcached(ctx, info, session)\nif conn == nil {\n    return &ScanResult{Success: false, Error: fmt.Errorf(\"%s\", i18n.GetText(\"memcached_connect_failed\"))}\n}\n// after\n// caller-side guard: verify reachability and retry once before treating as connect failure\nif !isTCPPortOpen(host, 11211, 3*time.Second) {\n    log.Printf(\"skip %s: port 11211 not reachable\", host)\n    return\n}\nresult := plugin.Scan(ctx, info, session) // retry logic configured via session timeouts","handlingStrategy":"validation","validationCode":"func ensureMemcachedDialable(target string, timeout time.Duration) error {\n\tconn, err := net.DialTimeout(\"tcp\", target, timeout)\n\tif err != nil { return fmt.Errorf(\"cannot reach %s: %w\", target, err) }\n\t_ = conn.Close()\n\treturn nil\n}\n// call before plugin.Scan\nif err := ensureMemcachedDialable(\"10.0.0.5:11211\", 3*time.Second); err != nil { log.Fatal(err) }","typeGuard":"func isConnectFailure(r *services.ScanResult) bool {\n\treturn r != nil && !r.Success && r.Error != nil && strings.Contains(r.Error.Error(), \"connect\")\n}","tryCatchPattern":"result := plugin.Scan(ctx, info, session)\nif !result.Success && isConnectFailure(result) {\n\tlog.Printf(\"skipping %s: TCP connect failed: %v\", info.Target(), result.Error)\n\treturn // do not retry immediately; check network first\n}","preventionTips":["Validate host:port reachability with a quick TCP dial before the full scan","Increase ModuleTimeout for high-latency or WAN targets","Ensure firewalls permit outbound connections to 11211-11213","Avoid scanning through misconfigured NAT/proxies that silently drop the connection"],"tags":["memcached","tcp","connect-failed","timeout"],"backgroundTag":"connection-refused","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}