How to stop Solana RPC 429 errors (Too Many Requests)
A 429 from a Solana RPC means you sent more requests per second than your plan allows. It always arrives at the worst time, because your bot is busiest exactly when the market is. Here is what is going on and how to make it stop.
Where 429s come from
- The public endpoint (
api.mainnet-beta.solana.com) is shared by everyone and limited hard. Some methods, such asgetTokenLargestAccountsandgetProgramAccounts, are refused almost every time. - Paid and free plans have a requests-per-second cap. A burst of parallel calls goes over it even if your average is low.
- Per-method limits. Heavy methods often have a lower cap than light ones.
- Disguised rate limits. Some endpoints answer HTTP 200 with a JSON-RPC error in the body:
{"code":429,"message":"Too many requests for a specific RPC call"}. Code that only checks the HTTP status misses it.
What actually fixes it
- Space your requests. If the plan allows 10 a second, send one every 100 ms, not ten at once.
- Use more than one endpoint. Two keys at 10 a second are 20 a second, and when one refuses, the other is still there.
- Back off the endpoint, not the request. When an endpoint refuses, rest that endpoint (honouring
Retry-Afterif it sends one) and send the call somewhere else straight away. - Batch.
getMultipleAccountsreads 100 accounts in one request. A JSON-RPC batch sends several calls in one HTTP request. - Do not retry real errors. "Invalid param" will be invalid on every endpoint. Retrying it only burns quota.
Working code
solana-rpc-pool does those five things, with no dependencies:
import { createPool } from "solana-rpc-pool";
const rpc = createPool({
endpoints: [
{ url: "https://rpc-one.example/?api-key=KEY_ONE", rps: 10 },
{ url: "https://rpc-two.example/?api-key=KEY_TWO", rps: 10 },
],
});
const slot = await rpc.call("getSlot");
const [epoch, height] = await rpc.batch([["getEpochInfo"], ["getBlockHeight"]]);
console.table(rpc.stats()); // calls, errors, rate-limit hits and latency per endpoint
Each endpoint gets its own rate. A 429, 403, 5xx or timeout rests that endpoint for 1 s, 2 s, 4 s, up to a minute, and the call moves to the next one. The public endpoint is used only as a last resort. Endpoints are named by host in errors and stats, so an API key never ends up in a log.
A note on keys
Using several keys is normal across providers or across projects you own. Check each provider's terms before stacking many free accounts with one of them.
When this is not enough
If you are polling the same data in a loop, a WebSocket subscription costs far less than repeated HTTP calls. See solana-ws-keepalive.