davila7/claude-code-templates / cli-tool/components/skills/development/cloudflare-deploy
cloudflare-deploy
FlaggedDeploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.
references/hyperdrive/gotchas.md
View on GitHub# Gotchas
See [README.md](./README.md), [configuration.md](./configuration.md), [api.md](./api.md), [patterns.md](./patterns.md).
## Common Errors
### "Too many open connections" / "Connection limit exceeded"
**Cause:** Workers have a hard limit of **6 concurrent connections per invocation**
**Solution:** Set `max: 5` in driver config, reuse connections, ensure proper cleanup with `client.end()` or `ctx.waitUntil(conn.end())`
### "Failed to acquire a connection (Pool exhausted)"
**Cause:** All connections in pool are in use, often due to long-running transactions
**Solution:** Reduce transaction duration, avoid queries >60s, don't hold connections during external calls, or upgrade to paid plan for more connections
### "connection_refused"
**Cause:** Database refusing connections due to firewall, connection limits, or service down
**Solution:** Check firewall allows Cloudflare IPs, verify DB listening on port, confirm service running, and validate credentials
### "Query timeout (deadline exceeded)"
**Cause:** Query execution exceeding 60s timeout limit
**Solution:** Optimize with indexes, reduce dataset with LIMIT, break into smaller queries, or use async processing
### "password authentication failed"
**Cause:** Invalid credentials in Hyperdrive configuration
**Solution:** Check username and password in Hyperdrive config match database credentials
### "SSL/TLS connection error"
**Cause:** SSL/TLS configuration mismatch between Hyperdrive and database
**Solution:** Add `sslmode=require` (Postgres) or `sslMode=REQUIRED` (MySQL), upload CA cert if self-signed, verify DB has SSL enabled, and check cert expiry
### "Queries not being cached"
**Cause:** Query is mutating (INSERT/UPDATE/DELETE), contains volatile functions (NOW(), RANDOM()), or caching disabled
**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.js
### "Slow multi-query Workers despite Hyperdrive"
**Cause:** Worker executing at edge, each query round-trips to DB region
**Solution:** Enable Smart Placement (`"placement": {"mode": "smart"}` in wrangler.jsonc) to execute Worker near DB. See [patterns.md](./patterns.md) Multi-Query pattern.
### "Local database connection failed"
**Cause:** `localConnectionString` incorrect or database not running
**Solution:** Verify `localConnectionString` correct, check DB running, confirm env var name matches binding, and test with psql/mysql client
### "Environment variable not working"
**Cause:** Environment variable format incorrect or not exported
**Solution:** Use format `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING>`, ensure binding matches wrangler.jsonc, export variable in shell, and restart wrangler dev
## Limits
| Limit | Free | Paid | Notes |
|-------|------|------|-------|
| Max configs | 10 | 25 | Hyperdrive configurations per account |
| Worker connections | 6 | 6 | Max concurrent connections per Worker invocation |
| Username/DB name | 63 bytes | 63 bytes | Maximum length |
| Connection timeout | 15s | 15s | Time to establish connection |
| Idle timeout | 10 min | 10 min | Connection idle timeout |
| Max origin connections | ~20 | ~100 | Connections to origin database |
| Query duration max | 60s | 60s | Queries >60s terminated |
| Cached response max | 50 MB | 50 MB | Responses >50MB returned but not cached |
## Resources
- [Docs](https://developers.cloudflare.com/hyperdrive/)
- [Getting Started](https://developers.cloudflare.com/hyperdrive/get-started/)
- [Wrangler Reference](https://developers.cloudflare.com/hyperdrive/reference/wrangler-commands/)
- [Supported DBs](https://developers.cloudflare.com/hyperdrive/reference/supported-databases-and-features/)
- [Discord #hyperdrive](https://discord.cloudflare.com)
- [Limit Increase Form](https://forms.gle/ukpeZVLWLnKeixDu7)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |