How to fix LIMIT_EXCEEDED in Salesforce deployments
A deployment's Apex tests, or the data load behind it, hit one of Salesforce's governor or org-wide limits.
Surfaces during: Apex test execution or bulk data operations, not metadata deploy validation itselfWhat it means
LIMIT_EXCEEDED covers a family of Salesforce limits, most commonly Apex governor limits like SOQL queries, DML statements, or CPU time, hit during the test execution a deployment requires. It can also mean an org-wide limit, like daily API calls or mass email recipients, was exceeded by automation the deployment triggers.
Per-transaction governor limits (100 SOQL queries, 150 DML statements, 10,000 CPU milliseconds synchronously) reset every transaction, so this almost always points at un-bulkified code inside one transaction rather than a genuine capacity ceiling on the org.
Common causes
The fix
- Bulkify the code path hitting the limitRewrite the trigger, class, or test to operate on collections instead of individual records, cutting SOQL and DML calls per transaction.
// Bad: SOQL inside a loop for (Account a : accounts) { List<Contact> cons = [SELECT Id FROM Contact WHERE AccountId = :a.Id]; } // Good: one query outside the loop Map<Id, List<Contact>> conMap = new Map<Id, List<Contact>>(); for (Contact c : [SELECT Id, AccountId FROM Contact WHERE AccountId IN :accountIds]) { if (!conMap.containsKey(c.AccountId)) conMap.put(c.AccountId, new List<Contact>()); conMap.get(c.AccountId).add(c); } - Reduce test data volume to the minimum neededScale back Apex test setup to the smallest data set that still exercises the logic being tested.
- Check org limits before large deploymentsReview API and other daily limits in Setup before running a bulk data load or deployment that adds to usage already consumed that day.
How Serpent prevents this
Serpent pools pre-warmed scratch orgs for test runs, so a bulk test or data load hits a clean set of limits instead of competing with everything else already running in a shared sandbox. See the Salesforce deployment error library.

Prevention
Related errors
LIMIT_EXCEEDED, answered
Start free. No credit card, no install, no commitment.
Set up in under 15 minutes. No DevOps hire needed.
