ipfs/kubo · error

failure to parse config setting IPNS.RecordLifetime: %s

Error message

failure to parse config setting IPNS.RecordLifetime: %s

What it means

The daemon parses IPNS.RecordLifetime with time.ParseDuration during Online node construction. If the configured string is not a valid Go duration (e.g. "1 day" or "24h30m" typos like "24h30"), fx construction aborts and the daemon exits with this error.

Source

Thrown at core/node/groups.go:344

	var repubPeriod, recordLifetime time.Duration

	if cfg.Ipns.RepublishPeriod != "" {
		d, err := time.ParseDuration(cfg.Ipns.RepublishPeriod)
		if err != nil {
			return fx.Error(fmt.Errorf("failure to parse config setting IPNS.RepublishPeriod: %s", err))
		}

		if !util.Debug && (d < time.Minute || d > (time.Hour*24)) {
			return fx.Error(fmt.Errorf("config setting IPNS.RepublishPeriod is not between 1min and 1day: %s", d))
		}

		repubPeriod = d
	}

	if cfg.Ipns.RecordLifetime != "" {
		d, err := time.ParseDuration(cfg.Ipns.RecordLifetime)
		if err != nil {
			return fx.Error(fmt.Errorf("failure to parse config setting IPNS.RecordLifetime: %s", err))
		}

		recordLifetime = d
	}

	isBitswapLibp2pEnabled := cfg.Bitswap.Libp2pEnabled.WithDefault(config.DefaultBitswapLibp2pEnabled)
	isBitswapServerEnabled := cfg.Bitswap.ServerEnabled.WithDefault(config.DefaultBitswapServerEnabled)
	isHTTPRetrievalEnabled := cfg.HTTPRetrieval.Enabled.WithDefault(config.DefaultHTTPRetrievalEnabled)

	// The Provide system handles both new CID announcements and periodic
	// re-announcements. Provide.Enabled=false fully disables it.
	// Provide.DHT.Interval=0 disables only the periodic reprovide schedule;
	// new CIDs still announce via fast-provide-root and 'ipfs provide once'.
	isProviderEnabled := cfg.Provide.Enabled.WithDefault(config.DefaultProvideEnabled)

	return fx.Options(
		fx.Provide(BitswapOptions(cfg)),
		fx.Provide(Bitswap(isBitswapServerEnabled, isBitswapLibp2pEnabled, isHTTPRetrievalEnabled)),

View on GitHub (pinned to 329838acdf)

Solutions

  1. Run `ipfs config Ipns.RecordLifetime` to inspect the value, then set a valid Go duration: `ipfs config Ipns.RecordLifetime 48h`
  2. Validate locally first: `go run` / quick check that `time.ParseDuration("<value>")` succeeds; valid units are ns, us, ms, s, m, h (no "d")
  3. Clear the setting to use the default record lifetime: `ipfs config --json Ipns.RecordLifetime ""`

Example fix

// before (config.json)
"Ipns": { "RecordLifetime": "2 days" }
// after
"Ipns": { "RecordLifetime": "48h" }
Defensive patterns

Strategy: validation

Validate before calling

if _, err := time.ParseDuration(cfg.Ipns.RecordLifetime); cfg.Ipns.RecordLifetime != "" && err != nil {
    return fmt.Errorf("IPNS.RecordLifetime %q is not a valid Go duration (units: ns,us,ms,s,m,h)", cfg.Ipns.RecordLifetime)
}

Prevention

When it happens

Trigger: IPNS.RecordLifetime is non-empty in the config and `ipfs daemon` starts; time.ParseDuration fails on the stored string.

Common situations: Human-style values like "1 week", "2 days" or "1d" are not Go durations; trailing whitespace or locale characters in a hand-edited config; scripts writing malformed values via `ipfs config`.

Understand the failure class

Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/9f3d359690102b3a. Report an issue: GitHub.