> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cosmos.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Recover from an app hash error

> For operators whose node stopped with wrong Block.Header.AppHash after an upgrade, this page gets the node back to the chain head without risking a double sign.

Commands on this page were run on gaia v29.1.0 (Cosmos SDK v0.53.8, CometBFT v0.38.25) on 2026-12-01 by agent testing on a local devnet.
Command names and flags were checked against gaia v29.2.0 on 2026-12-03.

This guide returns a node to the chain head after it stops with `wrong Block.Header.AppHash`. The error means the node computed a different state from the rest of the network. After an upgrade, the usual cause is a block executed with the wrong binary.

The wrong state is already on disk, so replacing the binary is only half of the fix. The node must also undo the bad block or restore its data.

## Before you begin

You have a node set up with [Run gaiad as a service](https://docs.cosmos.network/hub/latest/node/service.md), and its log shows this error:

```text theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
CONSENSUS FAILURE!!! err="+2/3 committed an invalid block: wrong Block.Header.AppHash.  Expected <hash>, got <hash>"
```

The process keeps running after this error, and RPC keeps answering at the same height. A node restarted in this state logs the same `wrong Block.Header.AppHash` message as `Error in validation`, then drops its peers.

Get two values from the [release notes](https://github.com/cosmos/gaia/releases) or the upgrade announcement:

* The version to run, and its commit if one is given.
* The upgrade height.

Set the node home used by the commands on this page:

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
export NODE_HOME=/var/lib/gaia/.gaia
```

The commands name the plain `gaiad` unit. For the Cosmovisor unit, use `cosmovisor` in the `systemctl` and `journalctl` lines.

## Find the binary that failed

1. Find the path of the running binary. The `gaiad` on your `PATH` can be a different file.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo readlink "/proc/$(pgrep -x gaiad)/exe"
   ```

   If the process has exited, the plain unit runs `/usr/local/bin/gaiad`. The Cosmovisor unit runs `cosmovisor/current/bin/gaiad` under the node home.

2. Ask the running node for its version.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   curl -s http://localhost:26657/abci_info | jq -r .result.response.version
   ```

3. Set the path from step 1 and print its version and commit.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   export FAILED_BIN=/usr/local/bin/gaiad
   sudo -u gaia "$FAILED_BIN" version --long | grep -E '^(version|commit):'
   ```

Compare the output with the release notes. A different version or commit means the wrong binary ran. If the versions from steps 2 and 3 differ, the file was replaced and the node was not restarted.

If the versions match the release notes, keep the log of the failure. Continue with the rollback, and report the failure as described in [If the error returns](#if-the-error-returns).

## Protect the signing key

> [!CAUTION]
>
> Keep one running node per consensus key, and never replace `priv_validator_state.json` with an older copy. Either mistake can cause a double sign. A double sign slashes 5 percent of stake and permanently tombstones the validator.

Stop the node and wait for `inactive`:

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
sudo systemctl stop gaiad
systemctl is-active gaiad
```

With a [remote signer](https://docs.cosmos.network/hub/latest/validators/remote-signing.md), the signer keeps this state. Leave the signer's state file as it is.

## Clear the halt settings

A `halt-height` at or below the next block stops the node again, even when that height has passed.

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
sudo -u gaia "$FAILED_BIN" config set app halt-height 0 --home "$NODE_HOME"
sudo -u gaia "$FAILED_BIN" config set app halt-time 0 --home "$NODE_HOME"
sudo grep -nE '^halt-(height|time)' "$NODE_HOME/config/app.toml"
```

Both values must print `0`.

## Roll back one block

1. Run the rollback with the binary that failed. A newer binary may expect stores that the old state does not have.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo -u gaia "$FAILED_BIN" rollback --home "$NODE_HOME"
   ```

   Success prints `Rolled back state to height <height>`, one below the height where the node stopped. The block stays on disk, and the node executes it again on restart. The rollback does not change `priv_validator_state.json`.

2. Install the correct binary. The plain unit runs `/usr/local/bin/gaiad`. The Cosmovisor unit runs the file that `current` points to. [Install gaiad](https://docs.cosmos.network/hub/latest/getting-started/installation.md) covers verification.

3. Check the version and commit of the installed file against the release notes, as in [Find the binary that failed](#find-the-binary-that-failed).

4. Start the node and watch the log.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo systemctl start gaiad
   journalctl -u gaiad -f -o cat | grep -E 'AppHash|committed state|step regression'
   ```

The `committed state` lines show a climbing height. Run the rollback once. A second run before the node starts changes nothing.

On a validator, the log also shows `error signing vote: step regression at height <height> round 0`. The signing state blocks a second signature at the rolled-back height and round, so this is not a double sign. On mainnet the validator misses that one signature and signs from the next round or height.

## If the error returns

Restore the data from a snapshot or with state sync when the rollback fails or the same error returns. Both need an empty `data/` directory. State sync skips a node that already has blocks, and the same error follows.

Use data from above the upgrade height. From a lower height, the node runs earlier blocks with the new binary, which can cause the same error.

1. Stop the node and wait for `inactive`.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo systemctl stop gaiad
   systemctl is-active gaiad
   ```

2. Back up the signing state. Do this now, even if you have an earlier copy, because the node can sign after a restart. If the file already shows height 0, the data was reset before. In that case, skip this step and keep the backup you have.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo cp -p "$NODE_HOME/data/priv_validator_state.json" "$NODE_HOME/priv_validator_state.json.bak"
   ```

3. Reset the data directory. This also resets `priv_validator_state.json` to height 0.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo -u gaia gaiad comet unsafe-reset-all --home "$NODE_HOME" --keep-addr-book
   ```

4. Load new data with one of these methods. Run the linked commands as the `gaia` user with `--home "$NODE_HOME"`.

   * Snapshot: [download and verify an archive](https://docs.cosmos.network/hub/latest/node/sync.md#restore-a-snapshot), then extract it into the node home.

     ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
     lz4 -dc cosmoshub-4-snapshot.tar.lz4 | sudo -u gaia tar -xf - -C "$NODE_HOME"
     ```

   * State sync: [fetch the trust values and write the configuration](https://docs.cosmos.network/hub/latest/node/sync.md#state-sync), and do not start the node yet. The trust height must be above the upgrade height.

5. Put the signing state back. A snapshot archive can contain another node's copy, so do this after extracting.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo cp -p "$NODE_HOME/priv_validator_state.json.bak" "$NODE_HOME/data/priv_validator_state.json"
   ```

6. If the rollback failed, install and check the correct binary now, as in steps 2 and 3 of [Roll back one block](#roll-back-one-block).

7. Start the node.

   ```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   sudo systemctl start gaiad
   ```

With state sync, the `Discovered new snapshot` lines must name a height above the upgrade height. Once the node has synced, set `statesync.enable` back to `false`.

If the correct binary produced the error, ask for help in the validator channels on the [Interchain Discord](https://discord.gg/interchain). Include the `version --long` output, the `abci_info` response, the log of the failure, and the recovery method you used.

## Verify

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -s http://localhost:26657/abci_info | jq -r .result.response.version
gaiad status | jq '{height: .sync_info.latest_block_height, catching_up: .sync_info.catching_up}'
```

The version matches the release notes. The height climbs past the block that failed, and `catching_up` is `false`.

On a validator, check for a jail after the node has caught up:

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
gaiad query slashing signing-info "$(sudo -u gaia gaiad comet show-validator --home "$NODE_HOME")"
gaiad query staking validator <cosmosvaloper>
```

With a [remote signer](https://docs.cosmos.network/hub/latest/validators/remote-signing.md), the local key is not the validator's key. Pass the signer's public key or the `cosmosvalcons` address to `signing-info` instead.

If the validator query shows `jailed: true`, wait until the `jailed_until` time in the signing info passes. Then follow [Unjail](https://docs.cosmos.network/hub/latest/validators/validator-setup.md#unjail).

## Next

[Upgrade a node](https://docs.cosmos.network/hub/latest/hub-tutorials/upgrade-node.md) covers the checks before the next upgrade. [Monitoring](https://docs.cosmos.network/hub/latest/validators/monitoring.md) covers alerts for a node that stops.
