Troubleshooting
Common Issues
1
"402 Payment Required" but I paid!
Cause: Payment signature invalid or expired
Fix:
// Ensure wallet is on correct network
const wallet = createWalletClient({
chain: baseSepolia, // Must match gateway network!
// ...
});
// Check facilitator URL
facilitatorUrl: 'https://x402.org/facilitator'; // Correct2
3
4
5
"Invalid secret token"
Cause: Origin server rejecting requests
Fix:
// In your origin API, accept Gate402 requests:
app.use((req, res, next) => {
const secret = req.headers['x-gate402-secret'];
// Allow if secret matches OR if no secret required
if (!process.env.GATE402_SECRET || secret === process.env.GATE402_SECRET) {
return next();
}
res.status(403).json({ error: 'Forbidden' });
});Error Codes
Code
Meaning
Solution
402
Payment Required
Send payment with PAYMENT-SIGNATURE header
403
Forbidden
Check secret token or IP whitelist
404
Gateway Not Found
Verify subdomain is correct
429
Too Many Requests
Slow down or upgrade plan
500
Server Error
Check origin API is responding
502
Bad Gateway
Origin API returned invalid response
504
Gateway Timeout
Origin API too slow (>30s)