{"record":{"id":"54a879fd81069f8d","repo":"ipfs/kubo","slug":"s-s-s","errorCode":null,"errorMessage":"%s (%s != %s)","messagePattern":"(.+?) \\((.+?) != (.+?)\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"core/corehttp/commands.go","lineNumber":222,"sourceCode":"}\n\n// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/kubo/` or `/go-ipfs/`\nfunc CheckVersionOption() ServeOption {\n\tdaemonVersion := version.ApiVersion\n\n\treturn func(n *core.IpfsNode, l net.Listener, parent *http.ServeMux) (*http.ServeMux, error) {\n\t\tmux := http.NewServeMux()\n\t\tparent.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\t\tif strings.HasPrefix(r.URL.Path, APIPath) {\n\t\t\t\tcmdqry := r.URL.Path[len(APIPath):]\n\t\t\t\tpth := strings.Split(cmdqry, \"/\")\n\n\t\t\t\t// backwards compatibility to previous version check\n\t\t\t\tif len(pth) >= 2 && pth[1] != \"version\" {\n\t\t\t\t\tclientVersion := r.UserAgent()\n\t\t\t\t\t// skips check if client is not kubo (go-ipfs)\n\t\t\t\t\tif (strings.Contains(clientVersion, \"/go-ipfs/\") || strings.Contains(clientVersion, \"/kubo/\")) && daemonVersion != clientVersion {\n\t\t\t\t\t\thttp.Error(w, fmt.Sprintf(\"%s (%s != %s)\", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmux.ServeHTTP(w, r)\n\t\t})\n\n\t\treturn mux, nil\n\t}\n}\n","sourceCodeStart":204,"sourceCodeEnd":234,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/corehttp/commands.go#L204-L234","documentation":"This is the concrete 400 response produced by the version-check middleware: \"<errAPIVersionMismatch> (<daemonVersion> != <clientVersion>)\". The middleware only applies when the User-Agent looks like a kubo/go-ipfs client and the requested path is not the version endpoint, keeping legacy behavior for version probing. See error 507 for the sentinel.","triggerScenarios":"A kubo user-agent HTTP client whose version differs from the daemon requests any /api/v0/ command other than version — e.g. an old `ipfs` binary or Go client pointed at a newer daemon via --api or IPFS_API.","commonSituations":"Mixed-version clusters and Docker swarms; CI using a stale ipfs binary against a freshly built daemon; users setting IPFS_API to a different machine's daemon after one side upgraded.","solutions":["Align versions: run a client (binary/library) matching the daemon's version.","Rebuild or reinstall the ipfs binary/tooling after upgrading the daemon.","Check both versions (`ipfs version --all` locally and remotely); the error body shows the exact mismatch.","Point the client at a daemon of its own version instead of a shared one of different vintage."],"exampleFix":"// before\nIPFS_API=/ip4/host/tcp/5001 ipfs id  # client v0.25 vs daemon v0.30 -> 400\n// after\nipfs version           # v0.30.0\n# use/rebuild a v0.30.0 client, then:\nIPFS_API=/ip4/host/tcp/5001 ipfs id","handlingStrategy":"retry","validationCode":"remote, err := shell.Version()\nif err != nil {\n\treturn err\n}\nif remote != version.ApiVersion { // from your client's kubo module\n\treturn fmt.Errorf(\"skip daemon %s: client is %s\", remote, version.ApiVersion)\n}","typeGuard":null,"tryCatchPattern":"res, err := shell.Post(ctx, \"id\", nil, nil)\nif err != nil && strings.Contains(err.Error(), \"api version mismatch\") {\n\t// fall back to a same-version daemon or surface an upgrade prompt\n\treturn fmt.Errorf(\"version mismatch with RPC daemon: %w\", err)\n}","preventionTips":["Check the daemon version via the version endpoint before issuing commands","Avoid pointing one binary at daemons of a different release; deploy binary and daemon together","In CI, install the ipfs binary from the same source revision as the daemon under test","Parse the \"(a != b)\" body to log which side needs upgrading"],"tags":["http","rpc","versioning","compatibility"],"backgroundTag":"api-version-mismatch","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}