{"id":"abd0b523081de13a","repo":"gofiber/fiber","slug":"prefork-w","errorCode":null,"errorMessage":"prefork: %w","messagePattern":"prefork: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"prefork.go","lineNumber":116,"sourceCode":"\t\t}\n\t\treturn nil\n\t}\n\n\t// Master callback: all children spawned → startup message & OnListen hooks\n\tp.OnMasterReady = func(childPIDs []int) error {\n\t\tlistenData := app.prepareListenData(addr, tlsConfig != nil, cfg, childPIDs)\n\t\tapp.runOnListenHooks(listenData)\n\t\tapp.printMessages(cfg, listenData)\n\t\treturn nil\n\t}\n\n\t// Master callback: child recovered after crash\n\tp.OnChildRecover = func(oldPID, newPID int) {\n\t\tlogger.Printf(\"prefork: child %d crashed, recovered with new PID %d\", oldPID, newPID)\n\t}\n\n\tif err := p.ListenAndServe(addr); err != nil {\n\t\treturn fmt.Errorf(\"prefork: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// dummyCmd is for internal prefork testing\nfunc dummyCmd() *exec.Cmd {\n\tcommand := \"go\"\n\tif storeCommand := dummyChildCmd.Load(); storeCommand != nil && storeCommand != \"\" {\n\t\tcommand = storeCommand.(string) //nolint:forcetypeassert,errcheck // We always store a string in here\n\t}\n\tif runtime.GOOS == windowsOS {\n\t\treturn exec.Command(\"cmd\", \"/C\", command, \"version\")\n\t}\n\treturn exec.Command(command, \"version\")\n}\n","sourceCodeStart":98,"sourceCodeEnd":133,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/prefork.go#L98-L133","documentation":"Fiber's prefork master (SO_REUSEPORT multi-process mode) failed to listen on addr: this wraps any error from fasthttp's prefork.ListenAndServe. Common causes: the address/port is already in use, binding a privileged port (<1024) without permission, SO_REUSEPORT unsupported on the platform/kernel, or a malformed address.","triggerScenarios":"app.Listen(\":80\", fiber.ListenConfig{EnablePrefork: true}) when the port is taken, prefork/REUSEPORT is unsupported, or a privileged port is bound without privileges; or an invalid address string.","commonSituations":"Running two preforked instances on the same port; older kernels/containers without SO_REUSEPORT; binding <1024 as non-root; leftover process holding the port.","solutions":["Ensure the port is free (lsof/ss) and not held by another process or a previous instance.","Confirm the OS supports SO_REUSEPORT (Linux >=3.9); disable EnablePrefork on unsupported platforms.","Use a non-privileged port, or grant CAP_NET_BIND_SERVICE / run as root only if a privileged port is required.","Verify the address string is well-formed (e.g. ':3000', '0.0.0.0:3000')."],"exampleFix":"// before\napp.Listen(\":80\", fiber.ListenConfig{EnablePrefork: true})\n// -> prefork: listen tcp :80: bind: address already in use\n\n// after: free port + non-privileged, confirm REUSEPORT\napp.Listen(\":3000\", fiber.ListenConfig{EnablePrefork: true})","handlingStrategy":"validation","validationCode":"// pre-flight: ensure the port is free before enabling prefork\nfunc portFree(addr string) bool {\n    ln, err := net.Listen(\"tcp\", addr)\n    if err != nil { return false }\n    _ = ln.Close()\n    return true\n}","typeGuard":null,"tryCatchPattern":"if err := app.Listen(addr, fiber.ListenConfig{EnablePrefork: true}); err != nil {\n    log.Fatalf(\"prefork listen failed: %v\", err)\n}","preventionTips":["Don't run two preforked servers on the same port.","Avoid EnablePrefork on platforms without SO_REUSEPORT.","Bind non-privileged ports in containers."],"tags":["prefork","network","startup","reuseport","fiber"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}