# Nonce too high: cause and fix

> Nonce too high means you sent a nonce above the account's next one. See why some nodes refuse it and others queue it, and how to fix your nonce count.

Source: https://hashspan.dev/errors/nonce-too-high

## Short answer

Every account's transactions must use nonces in order, starting from the account's next one. Nonce too high means yours skips ahead: earlier nonces were never sent. Some nodes refuse it, as Hardhat does while automining. Others accept it and keep it queued until the missing nonces arrive. Don't set the nonce by hand: let the client read the next one from the node, or send the missing nonces first.

## What you will see

- `nonce too high`
- `Nonce too high. Expected nonce to be 0 but got 5. Note that transactions can't be queued when automining.`
- `Nonce provided for the transaction (5) is higher than the next one expected.`

## Where does it stop?

Figure: A transaction's path from your code to the node, the mempool, a block and a receipt. The node's check is marked in red with the error nonce too high, and the later steps are dashed: no hash and no receipt.

The node compares your nonce with the account's next one before it accepts the transaction. If yours is higher, a node that refuses gaps sends it back at once: no hash, no block, no gas spent.

## What does the node check?

A [nonce](https://ethereum.org/developers/docs/accounts) counts the transactions an account has sent, and each one can be used once, in order. geth names this error for a nonce "higher than the next one expected based on the local chain" ([core/error.go](https://github.com/ethereum/go-ethereum/blob/master/core/error.go)).

What a node does with a gap differs. In our run, the same send had two outcomes:

Figure: A fresh account expects nonce 0; nonces 1 to 4 were never sent, and the send uses nonce 5. Hardhat with automining on refuses it with Nonce too high, expected nonce to be 0 but got 5: no hash. Anvil accepts it with a hash and queues it, so it waits for nonces 0 to 4. Hardhat with automining off also accepted a skipped nonce with a hash. The fix: let the client read the next nonce from the node.

A node that queues the gap gives no error now. The transaction waits instead, and you see it as a [transaction stuck pending](https://hashspan.dev/errors/transaction-stuck-pending).

## Why does it happen?

- **The nonce is set by hand.** Code passes a `nonce` it computed itself, and the count is ahead of the chain.
- **The chain was reset.** A local node restarted from an empty chain, but a script or wallet kept its old count.
- **Earlier sends failed.** Code that counts nonces moved on, but the transactions for the skipped nonces never reached the node.

## How do I fix it?

1. **Read the next nonce from the node.** With a `pending` block tag, the count includes transactions already waiting in the pool for the next blocks.
2. **Leave `nonce` out.** viem then asks the node for it before it sends. In our run, the same account sent fine once the nonce was left out.
3. **Or send the missing nonces first.** If the skipped transactions still matter, send them in order. The later one can follow.
4. **In an agent, keep one nonce source per account,** such as viem's `nonceManager`, so parallel tool calls don't count on their own. In our run, parallel sends that shared a count failed the other way, as [nonce too low](https://hashspan.dev/errors/nonce-too-low#what-happens-when-an-agent-sends-in-parallel). That run shows what a manager fixes and what it doesn't.

```ts
import type { Address, PublicClient } from 'viem';

declare const client: PublicClient;
declare const address: Address;
declare const myNonce: number; // the nonce your code was about to use

const next = await client.getTransactionCount({ address, blockTag: 'pending' });
if (myNonce > next) console.log(`nonce too high: the node expects ${next}, you have ${myNonce}`);
```

## What does it look like in a trace?

Like every refusal by the node, it is a `send` span that ends with an error and no hash:

Span `send 31337` (error):

| Attribute | Value |
|---|---|
| `error.type` | NonceTooHighError |
| `blockchain.tx.nonce` | 5 |
| `exception.message` | Nonce provided for the transaction (5) is higher than the next one expected. |
| `blockchain.tx.hash` | not set |

From the Hardhat run above. exception.message appears only with errorMessages set to sanitized.

The span records the nonce you sent, so compare it with the account's count at that time. A gap the node queued shows differently: the `send` succeeds and the [`confirm`](https://hashspan.dev/errors/transaction-stuck-pending#what-does-it-look-like-in-a-trace) span times out.

## FAQ

### Does nonce too high cost gas?

No. The node refuses the transaction before it reaches a block: no hash, no receipt, no fee.

### Why does Anvil not show this error?

In our run, Anvil accepted nonce 5 for a fresh account and kept it as queued. Hardhat with automining off also accepted a skipped nonce with a hash. The transaction then waits for the missing nonces, and the trouble shows up later as a transaction stuck pending.

### I restarted my local node and now get nonce too high. Why?

A restart can reset the chain, so every account's nonce starts again at 0. Anything that kept its own count, such as a script or a wallet, now sends a nonce the new chain hasn't reached. Reset that count, or let the client read the nonce from the node.

### What is the difference between nonce too high and nonce too low?

Too low means the nonce was already used, so the transaction can never run. Too high means it skips ahead: it can run only after the missing nonces are sent.
