solana-test-validator
Run solana-test-validator to get a single-node Solana cluster with JSON-RPC, faucet, and BPF program execution on localhost.
Search across all documentation pages
Run solana-test-validator to get a single-node Solana cluster with JSON-RPC, faucet, and BPF program execution on localhost.
Quick-reference recipe card - copy-paste ready.
solana-test-validator
solana-test-validator --reset
solana-test-validator --bpf-program <PROGRAM_ID> target/deploy/my_program.soWhen to reach for this:
anchor test.# Terminal 1: validator with your program preloaded
solana-test-validator --reset \
--bpf-program "$(solana-keygen pubkey target/deploy/my_program-keypair.json)" \
target/deploy/my_program.so
# Terminal 2: CLI + tests
solana config set --url http://127.0.0.1:8899
solana airdrop 5
anchor test --skip-local-validator # if validator already runningWhat this demonstrates:
--reset wipes ledger for deterministic runs.--bpf-program registers bytecode at a fixed program ID at genesis.test-ledger/ by default unless --ledger overrides.| Flag | Effect |
|---|---|
--reset | Delete existing ledger |
--ledger <PATH> | Persistent state directory |
--clone <PUBKEY> | Copy account from --url at start |
--bpf-program <ID> <SO> | Preload program binary |
--url <CLUSTER> | Source for clones |
# Quiet logs for CI
solana-test-validator --quiet --reset
# Bind custom RPC port
solana-test-validator --rpc-port 18899pkill solana-test-validator or change --rpc-port.--url mainnet-beta with --clone.--bpf-program ID must match client declare_id!. Fix: use keypair pubkey from target/deploy.solana logs connection errors.| Alternative | Use When | Don't Use When |
|---|---|---|
| Surfpool 0.12.0 | Mainnet-fork simulation | Minimal zero-dependency local tests |
| LiteSVM 0.6.x | Sub-second unit tests | Full RPC client integration |
| devnet | Shared staging environment | Fast inner dev loop |
anchor test embedded validator | One-command tests | Long-running manual session |
Default RPC 8899, gossip 8900, faucet 9900 - configurable via flags.
Yes - omit --reset and reuse --ledger path; beware state drift in tests.
Clone Token program IDs or use --bpf-program with known program pubkeys.
Yes - matches Agave 4.1.1 features including v0 transactions and ALTs when enabled in cluster features.
Start with tens, not thousands - each clone adds startup RPC fetch time.
Yes for CI - expose port 8899 to test containers.
Test validator tunes slot timing for developer throughput, not production consensus timing.
Ctrl+C in terminal; ensure no orphaned processes hold port 8899.
By default yes - use --skip-local-validator when you manage validator manually.
Yes on different --rpc-port values for parallel CI shards.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026