{"record":{"id":"dd2b34e17bcefb81","repo":"valyala/fasthttp","slug":"prefork-windows-only-supports-reuseport-true","errorCode":null,"errorMessage":"prefork: windows only supports reuseport = true","messagePattern":"prefork: windows only supports reuseport = true","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"prefork/prefork.go","lineNumber":51,"sourceCode":"\n\t// defaultShutdownGracePeriod is how long the master waits for children to\n\t// exit cleanly after sending SIGTERM before forcibly killing them.\n\tdefaultShutdownGracePeriod = 5 * time.Second\n)\n\nvar (\n\tdefaultLogger = Logger(log.New(os.Stderr, \"\", log.LstdFlags))\n\n\t// tcpListenerFile is a hook for (*net.TCPListener).File so tests can\n\t// inject failure paths without binding a real socket.\n\ttcpListenerFile = (*net.TCPListener).File\n\n\t// ErrOverRecovery is returned when child prefork process restarts exceed\n\t// the value of RecoverThreshold.\n\tErrOverRecovery = errors.New(\"prefork: exceeding the value of recoverthreshold\")\n\n\t// ErrOnlyReuseportOnWindows is returned when running on Windows without Reuseport.\n\tErrOnlyReuseportOnWindows = errors.New(\"prefork: windows only supports reuseport = true\")\n\n\t// ErrCommandProducerNilCmd is returned when a CommandProducer returns\n\t// (nil, nil) instead of a started command.\n\tErrCommandProducerNilCmd = errors.New(\"prefork: commandproducer returned nil command\")\n\n\t// ErrCommandProducerNotStarted is returned when a CommandProducer returns\n\t// an *exec.Cmd whose Process is nil (i.e. cmd.Start() was not called).\n\tErrCommandProducerNotStarted = errors.New(\"prefork: commandproducer must return a started command\")\n)\n\n// Logger is used for logging formatted messages. Its method set is intentionally\n// identical to fasthttp.Logger so that *fasthttp.Server.Logger can be assigned\n// directly.\ntype Logger interface {\n\t// Printf must have the same semantics as log.Printf.\n\tPrintf(format string, args ...any)\n}\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/prefork/prefork.go#L33-L69","documentation":"ErrOnlyReuseportOnWindows is returned by fasthttp's prefork package when Prefork is enabled on Windows without setting Reuseport to true. On Windows, prefork relies exclusively on SO_REUSEPORT-style socket sharing; without it, child processes cannot share the listening socket, so the library refuses to start rather than misbehave.","triggerScenarios":"Calling prefork (e.g. prefork.Start or app startup with Prefork enabled) on a Windows host while preforker.Reuseport is false (the default).","commonSituations":"Developers enabling prefork on Windows dev machines or Windows Server deployments after copying Linux-oriented prefork config; forgetting that Reuseport must be explicitly opted into on Windows.","solutions":["Set Reuseport: true on the preforker before starting on Windows.","Alternatively, disable prefork on Windows (enable it only on Linux/BSD builds).","Run the preforked service on a Linux/Unix host where Reuseport is not mandatory."],"exampleFix":"// before\npf := &prefork.Prefork{RecoverThreshold: 3}\n// after\npf := &prefork.Prefork{RecoverThreshold: 3, Reuseport: true} // required on Windows","handlingStrategy":"validation","validationCode":"if runtime.GOOS == \"windows\" && !pf.Reuseport {\n    pf.Reuseport = true // prefork on Windows requires Reuseport\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set Reuseport: true whenever prefork is enabled, unconditionally — it's harmless on Linux.","Add a startup unit test asserting prefork config per-OS.","CI: smoke-test prefork startup on a Windows runner if you ship Windows binaries."],"tags":["prefork","windows","configuration"],"backgroundTag":"prefork-reuseport-required-on-windows","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}