OpenNHP/opennhp · error
registration failed
Error message
registration failed
What it means
Companion to "registration failed: %s": when the server reports failure but the response carries no message text, runRegisterApp returns the bare "registration failed" error. It preserves deferred cleanup and non-zero exit while signaling that the server rejected the registration without explaining why.
Solutions
- Enable debug logging on both agent and server to find the underlying rejection cause.
- Verify the agent's keys match the server's peer table (PubKeyBase64 for the target cluster).
- Check server logs around the registration time for plugin AuthWithNHP messages.
- Retry registration; if intermittent, check UDP connectivity/firewall between agent and server (port 10581).
Example fix
// config.toml // before logLevel = 2 // after logLevel = 0 # debug on both agent and server, then re-run registration
Defensive patterns
Strategy: retry
Validate before calling
if resp == nil || (!resp.Success && resp.ErrMsg == "") {
log.Debug("registration rejected without detail; check server logs")
} Try / catch
if err := runRegisterApp(a, args); err != nil {
if err.Error() == "registration failed" {
log.Debug("no server detail; enable debug logs on server and retry")
}
return err
} Prevention
- Run agent and server at debug log level during first registration.
- Verify peer PubKeyBase64 entries match on both sides.
- Confirm UDP connectivity to the server's knock port before registering.
When it happens
Trigger: runRegisterApp receives a failed registration response where errMsgStr == "" — e.g. a generic NHP_ACK failure/timeout result with no detailed error field.
Common situations: Server rejecting on basic crypto/packet grounds before producing a plugin message; key mismatch causing a malformed exchange; older server version that doesn't populate the error message field; network interruption mid-registration.
Related errors
- registration failed
- AuthServiceId is required
- no server cluster: set Cluster in resource.toml or use…
- failed to create device from new key
- keystore: query pubkey conflict
AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07).
Data as JSON: /api/errors/d2331e6f11f478a2.
Report an issue: GitHub.
Appendix: source
Thrown at endpoints/agent/main/main.go:654
errCode = rakMsg.ErrCode
if rakMsg.ErrMsg != "" {
errMsgStr = rakMsg.ErrMsg
}
}
fmt.Println()
fmt.Printf(" %s❌ Registration failed%s\n", colorYellow, colorReset)
if errCode != "" {
fmt.Printf(" %sError code:%s %s\n", colorYellow, colorReset, errCode)
}
fmt.Printf(" %sError:%s %s\n", colorYellow, colorReset, errMsgStr)
fmt.Println()
// Return the error instead of os.Exit so the deferred a.Stop()
// (and any other cleanup) still runs. main() maps a non-nil error
// to a non-zero exit code.
if errMsgStr != "" {
return fmt.Errorf("registration failed: %s", errMsgStr)
}
return fmt.Errorf("registration failed")
}
// Registration succeeded — print results.
pubKey := a.PublicKeyBase64ByCipherScheme()
privKey := a.PrivateKeyBase64()
fmt.Println()
fmt.Printf(" %s✅ Registration successful!%s\n", colorGreen, colorReset)
fmt.Println()
fmt.Printf(" %sEmail (UserId):%s %s\n", colorYellow, colorReset, email)
fmt.Printf(" %sAuthServiceId:%s %s\n", colorYellow, colorReset, aspId)
if orgId != "" {
fmt.Printf(" %sOrganization:%s %s\n", colorYellow, colorReset, orgId)
}
if deviceId != "" {
fmt.Printf(" %sDevice ID:%s %s\n", colorYellow, colorReset, deviceId)
}
fmt.Printf(" %sCipher scheme:%s %s\n", colorYellow, colorReset, func() string {
if cipherScheme == common.CIPHER_SCHEME_GMSM {View on GitHub (pinned to 6e04ca5ff0)