Alchemy Common Errors
Overview
Troubleshooting guide for Alchemy SDK errors covering rate limits, RPC failures, invalid parameters, and network-specific issues.
Prerequisites
- A reproducible failing request that records its network, method, sanitized
parameters, timestamp, response code, and request/correlation ID where
available—never the API key or private key.
- Access to the appropriate Alchemy dashboard and a non-production key when
testing a fix.
- A defined retry budget and an application fallback for requests that cannot
safely be retried.
Instructions
- Classify the failure with the error reference and confirm the intended
network, RPC method, and parameter shape.
- Reproduce it with a scoped development key or a public test fixture, then
inspect account limits and service status without exposing credentials.
- Apply the smallest appropriate repair: correct parameters, back off for
429, paginate a large query, or switch to the documented supported API.
- Verify the corrected request and record the sanitized outcome; escalate
persistent provider failures with the correlation or request ID.
Error Reference
Authentication & Rate Limits
| HTTP Code |
Error |
Root Cause |
Fix |
401 |
Unauthorized |
Invalid or missing API key |
Verify key in Alchemy Dashboard |
403 |
Forbidden |
API key disabled or app deleted |
Create new app in Dashboard |
429 |
Too Many Requests |
Rate limit exceeded |
Implement backoff; upgrade plan |
429 |
Compute Units exceeded |
CU quota depleted |
Check CU usage in Dashboard |
Alchemy Rate Limits by Plan
| Plan |
Compute Units/sec |
Throughput |
| Free |
330 CU/s |
~25 requests/s |
| Growth |
660 CU/s |
~50 requests/s |
| Scale |
Custom |
Custom |
RPC & Query Errors
// Common RPC error handler
import { Alchemy, Network } from 'alchemy-sdk';
async function safeAlchemyCall<T>(
operation: () => Promise<T>,
context: string
): Promise<T | null> {
try {
return await operation();
} catch (error: any) {
const code = error.code || error.response?.status;
switch (code) {
case -32602: // Invalid params
console.error(`[${context}] Invalid parameters: ${error.message}`);
console.error('Common causes: wrong address format, invalid block number, missing 0x prefix');
break;
case -32600: // Invalid request
console.error(`[${context}] Malformed JSON-RPC request`);
break;
case -32601: // Method not found
console.error(`[${context}] RPC method not available on this network`);
console.error('Some Enhanced APIs are Ethereum-only');
break;
case -32000: // Server error
console.error(`[${context}] Node server error — usually transient, retry`);
break;
case 429:
const retryAfter = error.response?.headers?.['retry-after'] || 1;
console.error(`[${context}] Rate limited — retry after ${retryAfter}s`);
break;
default:
console.error(`[${context}] Unknown error: ${code} — ${error.message}`);
}
return null;
}
}
NFT API Errors
| Error |
Root Cause |
Fix |
Empty ownedNfts |
Address has no NFTs on this chain |
Check correct network |
Missing image.cachedUrl |
IPFS/Arweave gateway timeout |
Use image.originalUrl fallback |
getNftsForContract empty |
Contract not indexed |
Wait for indexing; try refreshContract |
| Spam NFTs in results |
No spam filter |
Add excludeFilters: ['SPAM'] option |
getNftMetadataBatch fails |
Batch too large |
Limit to 100 tokens per batch |
Enhanced API Errors
| Error |
Root Cause |
Fix |
getAssetTransfers empty |
Wrong category |
Include all: EXTERNAL, ERC20, ERC721, ERC1155 |
getTokenBalances timeout |
Too many tokens |
Paginate or use specific contract addresses |
getTokenMetadata null fields |
Token not verified |
Handle null name/symbol gracefully |
| WebSocket disconnect |
Idle timeout (5 min) |
Implement auto-reconnect logic |
Network-Specific Issues
// Diagnostic function
async function diagnoseAlchemyIssue(alchemy: Alchemy): Promise<string[]> {
const issues: string[] = [];
try {
const blockNumber = await alchemy.core.getBlockNumber();
console.log(`Connected: block #${blockNumber}`);
} catch (err: any) {
if (err.message?.includes('apiKey')) issues.push('API key invalid or missing');
else if (err.code === 'ECONNREFUSED') issues.push('Cannot reach Alchemy servers — check network');
else issues.push(`Connection error: ${err.message}`);
}
return issues;
}
Quick Diagnostic
# Test Alchemy API directly
curl -s "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":0}' | jq .
# Check CU usage (requires auth token)
curl -s "https://dashboard.alchemy.com/api/stats" \
-H "Authorization: Bearer ${ALCHEMY_AUTH_TOKEN}" | jq .
Output
- Error classified by type (auth, rate limit, RPC, network)
- Root cause identified with specific fix
- Diagnostic function for automated troubleshooting
Examples
When a testnet getAssetTransfers call returns 429, retain the sanitized
method, network, response headers, and request ID, then make the retry helper
honor Retry-After within the configured budget. Confirm the retry succeeds
against the expected testnet or produces a controlled unavailable result when
the budget is exhausted. If the dashboard shows a disabled key or depleted
quota, stop retries and correct the account configuration; do not substitute a
production credential or place it in a curl command committed to the project.
Error Handling
| Failure class |
Safe handling |
401 or 403 |
Stop the request, verify the scoped key’s application and network, and rotate a suspected exposure. |
429 or transient 5xx |
Use bounded backoff and surface an operator-visible unavailable state after the retry budget. |
| Invalid RPC parameters |
Validate address, chain, and block inputs before retrying; a retry cannot repair malformed input. |
| Unknown provider failure |
Preserve only sanitized request metadata and escalate with the request/correlation ID. |
Resources
Next Steps
For collecting debug bundles, see alchemy-debug-bundle.
1---2name: alchemy-common-errors3description: Diagnose and fix common Alchemy SDK and Web3 API errors. Use when encountering rate limits, RPC failures, invalid parameters, or blockchain query errors with the Alchemy SDK. Trigger: "alchemy error", "alchemy not working", "alchemy 429", "alchemy debug", "fix alchemy issue".4license: MIT5---6# Alchemy Common Errors
7
8## Overview
9
10Troubleshooting guide for Alchemy SDK errors covering rate limits, RPC failures, invalid parameters, and network-specific issues.
11
12## Prerequisites
13
14- A reproducible failing request that records its network, method, sanitized
15 parameters, timestamp, response code, and request/correlation ID where
16 available—never the API key or private key.
17- Access to the appropriate Alchemy dashboard and a non-production key when
18 testing a fix.
19- A defined retry budget and an application fallback for requests that cannot
20 safely be retried.
21
22## Instructions
23
241. Classify the failure with the error reference and confirm the intended
25 network, RPC method, and parameter shape.
262. Reproduce it with a scoped development key or a public test fixture, then
27 inspect account limits and service status without exposing credentials.
283. Apply the smallest appropriate repair: correct parameters, back off for
29 `429`, paginate a large query, or switch to the documented supported API.
304. Verify the corrected request and record the sanitized outcome; escalate
31 persistent provider failures with the correlation or request ID.
32
33## Error Reference
34
35### Authentication & Rate Limits
36
37| HTTP Code | Error | Root Cause | Fix |
38|-----------|-------|-----------|-----|
39| `401` | Unauthorized | Invalid or missing API key | Verify key in Alchemy Dashboard |
40| `403` | Forbidden | API key disabled or app deleted | Create new app in Dashboard |
41| `429` | Too Many Requests | Rate limit exceeded | Implement backoff; upgrade plan |
42| `429` | Compute Units exceeded | CU quota depleted | Check CU usage in Dashboard |
43
44### Alchemy Rate Limits by Plan
45
46| Plan | Compute Units/sec | Throughput |
47|------|-------------------|------------|
48| Free | 330 CU/s | ~25 requests/s |
49| Growth | 660 CU/s | ~50 requests/s |
50| Scale | Custom | Custom |
51
52### RPC & Query Errors
53
54```typescript
55// Common RPC error handler
56import { Alchemy, Network } from 'alchemy-sdk';
57
58async function safeAlchemyCall<T>(
59 operation: () => Promise<T>,
60 context: string
61): Promise<T | null> {
62 try {
63 return await operation();
64 } catch (error: any) {
65 const code = error.code || error.response?.status;
66
67 switch (code) {
68 case -32602: // Invalid params
69 console.error(`[${context}] Invalid parameters: ${error.message}`);
70 console.error('Common causes: wrong address format, invalid block number, missing 0x prefix');
71 break;
72
73 case -32600: // Invalid request
74 console.error(`[${context}] Malformed JSON-RPC request`);
75 break;
76
77 case -32601: // Method not found
78 console.error(`[${context}] RPC method not available on this network`);
79 console.error('Some Enhanced APIs are Ethereum-only');
80 break;
81
82 case -32000: // Server error
83 console.error(`[${context}] Node server error — usually transient, retry`);
84 break;
85
86 case 429:
87 const retryAfter = error.response?.headers?.['retry-after'] || 1;
88 console.error(`[${context}] Rate limited — retry after ${retryAfter}s`);
89 break;
90
91 default:
92 console.error(`[${context}] Unknown error: ${code} — ${error.message}`);
93 }
94 return null;
95 }
96}
97```
98
99### NFT API Errors
100
101| Error | Root Cause | Fix |
102|-------|-----------|-----|
103| Empty `ownedNfts` | Address has no NFTs on this chain | Check correct network |
104| Missing `image.cachedUrl` | IPFS/Arweave gateway timeout | Use `image.originalUrl` fallback |
105| `getNftsForContract` empty | Contract not indexed | Wait for indexing; try `refreshContract` |
106| Spam NFTs in results | No spam filter | Add `excludeFilters: ['SPAM']` option |
107| `getNftMetadataBatch` fails | Batch too large | Limit to 100 tokens per batch |
108
109### Enhanced API Errors
110
111| Error | Root Cause | Fix |
112|-------|-----------|-----|
113| `getAssetTransfers` empty | Wrong category | Include all: EXTERNAL, ERC20, ERC721, ERC1155 |
114| `getTokenBalances` timeout | Too many tokens | Paginate or use specific contract addresses |
115| `getTokenMetadata` null fields | Token not verified | Handle null `name`/`symbol` gracefully |
116| WebSocket disconnect | Idle timeout (5 min) | Implement auto-reconnect logic |
117
118### Network-Specific Issues
119
120```typescript
121// Diagnostic function
122async function diagnoseAlchemyIssue(alchemy: Alchemy): Promise<string[]> {
123 const issues: string[] = [];
124
125 try {
126 const blockNumber = await alchemy.core.getBlockNumber();
127 console.log(`Connected: block #${blockNumber}`);
128 } catch (err: any) {
129 if (err.message?.includes('apiKey')) issues.push('API key invalid or missing');
130 else if (err.code === 'ECONNREFUSED') issues.push('Cannot reach Alchemy servers — check network');
131 else issues.push(`Connection error: ${err.message}`);
132 }
133
134 return issues;
135}
136```
137
138## Quick Diagnostic
139
140```bash
141# Test Alchemy API directly
142curl -s "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" \
143 -X POST \
144 -H "Content-Type: application/json" \
145 -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":0}' | jq .
146
147# Check CU usage (requires auth token)
148curl -s "https://dashboard.alchemy.com/api/stats" \
149 -H "Authorization: Bearer ${ALCHEMY_AUTH_TOKEN}" | jq .
150```
151
152## Output
153
154- Error classified by type (auth, rate limit, RPC, network)
155- Root cause identified with specific fix
156- Diagnostic function for automated troubleshooting
157
158## Examples
159
160When a testnet `getAssetTransfers` call returns `429`, retain the sanitized
161method, network, response headers, and request ID, then make the retry helper
162honor `Retry-After` within the configured budget. Confirm the retry succeeds
163against the expected testnet or produces a controlled unavailable result when
164the budget is exhausted. If the dashboard shows a disabled key or depleted
165quota, stop retries and correct the account configuration; do not substitute a
166production credential or place it in a curl command committed to the project.
167
168## Error Handling
169
170| Failure class | Safe handling |
171|---------------|---------------|
172| `401` or `403` | Stop the request, verify the scoped key’s application and network, and rotate a suspected exposure. |
173| `429` or transient `5xx` | Use bounded backoff and surface an operator-visible unavailable state after the retry budget. |
174| Invalid RPC parameters | Validate address, chain, and block inputs before retrying; a retry cannot repair malformed input. |
175| Unknown provider failure | Preserve only sanitized request metadata and escalate with the request/correlation ID. |
176
177## Resources
178
179- [Alchemy Error Codes](https://www.alchemy.com/docs/reference/error-reference)
180- Alchemy Rate Limits
181- [JSON-RPC Error Codes](https://www.jsonrpc.org/specification#error_object)
182
183## Next Steps
184
185For collecting debug bundles, see `alchemy-debug-bundle`.