Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/hyperdrive/gotchas.md
1# Gotchas23See [README.md](./README.md), [configuration.md](./configuration.md), [api.md](./api.md), [patterns.md](./patterns.md).45## Common Errors67### "Too many open connections" / "Connection limit exceeded"89**Cause:** Workers have a hard limit of **6 concurrent connections per invocation**10**Solution:** Set `max: 5` in driver config, reuse connections, ensure proper cleanup with `client.end()` or `ctx.waitUntil(conn.end())`1112### "Failed to acquire a connection (Pool exhausted)"1314**Cause:** All connections in pool are in use, often due to long-running transactions15**Solution:** Reduce transaction duration, avoid queries >60s, don't hold connections during external calls, or upgrade to paid plan for more connections1617### "connection_refused"1819**Cause:** Database refusing connections due to firewall, connection limits, or service down20**Solution:** Check firewall allows Cloudflare IPs, verify DB listening on port, confirm service running, and validate credentials2122### "Query timeout (deadline exceeded)"2324**Cause:** Query execution exceeding 60s timeout limit25**Solution:** Optimize with indexes, reduce dataset with LIMIT, break into smaller queries, or use async processing2627### "password authentication failed"2829**Cause:** Invalid credentials in Hyperdrive configuration30**Solution:** Check username and password in Hyperdrive config match database credentials3132### "SSL/TLS connection error"3334**Cause:** SSL/TLS configuration mismatch between Hyperdrive and database35**Solution:** Add `sslmode=require` (Postgres) or `sslMode=REQUIRED` (MySQL), upload CA cert if self-signed, verify DB has SSL enabled, and check cert expiry3637### "Queries not being cached"3839**Cause:** Query is mutating (INSERT/UPDATE/DELETE), contains volatile functions (NOW(), RANDOM()), or caching disabled40**Solution:** Verify query is non-mutating SELECT, avoid volatile functions, confirm caching enabled, use `wrangler dev --remote` to test, and set `prepare=true` for postgres.js4142### "Slow multi-query Workers despite Hyperdrive"4344**Cause:** Worker executing at edge, each query round-trips to DB region45**Solution:** Enable Smart Placement (`"placement": {"mode": "smart"}` in wrangler.jsonc) to execute Worker near DB. See [patterns.md](./patterns.md) Multi-Query pattern.4647### "Local database connection failed"4849**Cause:** `localConnectionString` incorrect or database not running50**Solution:** Verify `localConnectionString` correct, check DB running, confirm env var name matches binding, and test with psql/mysql client5152### "Environment variable not working"5354**Cause:** Environment variable format incorrect or not exported55**Solution:** Use format `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING>`, ensure binding matches wrangler.jsonc, export variable in shell, and restart wrangler dev5657## Limits5859| Limit | Free | Paid | Notes |60|-------|------|------|-------|61| Max configs | 10 | 25 | Hyperdrive configurations per account |62| Worker connections | 6 | 6 | Max concurrent connections per Worker invocation |63| Username/DB name | 63 bytes | 63 bytes | Maximum length |64| Connection timeout | 15s | 15s | Time to establish connection |65| Idle timeout | 10 min | 10 min | Connection idle timeout |66| Max origin connections | ~20 | ~100 | Connections to origin database |67| Query duration max | 60s | 60s | Queries >60s terminated |68| Cached response max | 50 MB | 50 MB | Responses >50MB returned but not cached |6970## Resources7172- [Docs](https://developers.cloudflare.com/hyperdrive/)73- [Getting Started](https://developers.cloudflare.com/hyperdrive/get-started/)74- [Wrangler Reference](https://developers.cloudflare.com/hyperdrive/reference/wrangler-commands/)75- [Supported DBs](https://developers.cloudflare.com/hyperdrive/reference/supported-databases-and-features/)76- [Discord #hyperdrive](https://discord.cloudflare.com)77- [Limit Increase Form](https://forms.gle/ukpeZVLWLnKeixDu7)78