Bitbucket "Maximum number of services" Exceeded in a Step
A step listed more service containers than Bitbucket permits. There is a hard cap on how many services one step can attach, regardless of memory.
What this error means
The pipeline fails validation noting the step exceeds the maximum number of services. It is a structural limit, so it fails before the step runs.
Configuration error: step defines 6 services but the maximum
number of services per step is 5.Common causes
Too many services attached to one step
Bitbucket caps the number of services a single step can run. Listing more than the limit is rejected up front.
Services that could be combined or dropped
Some "services" are only needed by part of the work and could move to a separate step, or be merged (e.g. one database image instead of several).
How to fix it
Split services across steps
Move services to the specific steps that need them so no single step exceeds the cap.
- step:
name: API tests
services: [ postgres, redis ]
script: [ ./test-api.sh ]
- step:
name: Search tests
services: [ elasticsearch ]
script: [ ./test-search.sh ]Remove services the step does not use
- Audit which services each step actually connects to.
- Drop unused services from that step’s
services:list. - Consolidate duplicates where one container can serve multiple needs.
How to prevent it
- Attach a service only to the steps that use it.
- Keep service counts per step within Bitbucket’s limit.
- Prefer fewer, shared services over many narrow ones.