**Title: Preview deploys consistently failing at createSiteDatabaseBranch (HTTP 500) — branch count stuck at 250/300, automatic cleanup not working**

Hi all,

I’m hoping someone here has seen this before, since a support ticket can take up to 2 weeks and this is actively blocking my preview workflow.

The problem
Preview deploys on my site fail during database branch provisioning. The Netlify API returns an internal HTTP 500 on createSiteDatabaseBranch, before dependencies are installed, functions are bundled, or migrations run. Production deploys (merging into main) succeed reliably and repeatedly, using the exact same migrations and functions as the failing previews.

What I’ve found investigating this myself

  1. My project’s Database page (Data & storage > Database) shows 250 of 300 branches in use.
  2. Netlify’s own documentation states additional branches are created for any Agent Run, GitHub PR or Git branch, and are automatically deleted when the associated deploy previews are deleted. However, my branch list still shows branches from agent runs that are 2+ days old and long since irrelevant.
  3. To test this, I manually deleted ~10-15 old, failed preview deploys via “Delete deploy” on each deploy’s page, then re-checked the Database page. The branch count did not change — still 250/300. So deleting the deploy does not trigger the documented automatic branch cleanup.
  4. I ran netlify database status and netlify database status --branch <branch> via the CLI — no explicit “branch limit reached” message came back, just the generic provisioning failure on new preview attempts.

My question to the community

  • Has anyone else seen automatic database-branch cleanup silently fail to trigger after deleting a deploy preview?
  • Is there a known workaround to force-delete stale branches in bulk (via API or otherwise) when the dashboard/CLI doesn’t seem to remove them?
  • Could approaching the branch limit (250/300) actually be the cause of the createSiteDatabaseBranch 500, even before hitting 300 exactly?

I’ve already opened a support ticket with this same evidence, but wanted to check here in parallel given the 2-week turnaround. Happy to share more detail (deploy IDs, timestamps, screenshots) if useful.

Thanks in advance!

Update: I found a related, unresolved thread describing what looks like the exact same underlying issue — phantom database branches that count against the limit but can’t be deleted, causing repeated failures:

In that thread, the reporter even tried deleting the stale branches via Netlify’s own AI agent and got a 401 Unauthorized on the database management endpoints — so it doesn’t look like a self-service fix is available on the user’s end. That thread doesn’t show a resolution either, so this seems to be a known, recurring platform issue rather than anything specific to my project.

Tagging this in case it helps connect the dots for whoever picks up either ticket.

Hi Eric,

Thanks for reaching out to Netlify!

We have confirmed from our logs that your site’s database integration is functioning correctly for production deploys, with migrations applying successfully on every production build. The issue is isolated to preview deploys, exactly as you described.

On your question about the HTTP 500 versus the exact “branch limit reached” message: you are correct to notice the difference. The generic 500 you are seeing on the createSiteDatabaseBranch endpoint can occur when the branch count is close to but not yet at the hard limit. The specific “branch limit reached” message is returned only when the limit is hit exactly. Operating near the ceiling of 300 branches can cause provisioning attempts to fail intermittently as the system races to allocate, which aligns with what you are experiencing at 250 of 300.

On automatic cleanup: this is a confirmed gap. Branch cleanup is designed to trigger when associated deploy previews are deleted, but branches created by agent runs follow a separate lifecycle and are not automatically removed when an agent run completes. This means a site that uses agent runs frequently can accumulate branches that are never reclaimed, which is what you are observing.

On bulk deletion: we want to be transparent with you here. Bulk deletion of database branches from the dashboard is not currently available. Individual branches can be deleted one at a time from the Data and Storage section of your site settings. We understand this is not practical given your current branch count, and your case has been flagged internally to discuss whether a backend cleanup can be performed for your account while the broader fix is being worked on.

We will follow up once we have more clarity on both the cleanup bug and what can be done for your current branch count. In the meantime, deleting branches individually from the database page (rather than via the deploy deletion flow) is the most direct way to reclaim capacity.

Thank you again for the level of detail you provided. It genuinely speeds up the investigation on our end.

Reference links:

Netlify Database branch overview: https://docs.netlify.com/storage/database/ Managing database branches: https://docs.netlify.com/storage/database/#database-branches Deploy previews and branch deploys: https://docs.netlify.com/site-deploys/deploy-previews/

Let us know if you need further assistance.

Best regards,