It works in testing and fails in production: common causes and a first step

Works in testing but fails in production? Five common causes (configuration, data, load, dependencies, versions) and a first step for each one.

Fork with a rollback path over Nubyron brand lines: why what passes in testing fails in production

The short answer

The code passed the tests, the deployment went well and, in production, something fails. It is not bad luck: the test environment only predicts production to the extent that it resembles it. These are five differences that are often behind it and, for each one, a first step your team can take today.

Before looking for the cause: pin down what fails and when

Google’s Site Reliability Engineering book proposes monitoring four signals: latency, traffic, errors and saturation. And it advises putting more effort into detecting symptoms than causes. Common first step: note the exact time and the operation that fails (which action, by what type of user and with what error; without copying personal data) and look at those four signals in that window. Without that, every hypothesis is an assumption.

Cause 1: the configuration or secrets are different

The Twelve-Factor App defines configuration as “everything that is likely to vary between deploys” and recommends storing it in environment variables, not in the code. When it is maintained by hand, differences appear: an address, a permission, a toggle.

First step: export the names and the non-secret values from both environments; for secrets, compare only that they exist and their version or rotation date, never the value. Put them in two columns and review every difference.

Cause 2: the data is not alike

In testing there are few rows, and clean ones; in production there is volume, empty values, odd characters and old records. Microsoft recommends diverse test data, with edge cases such as large loads or complex queries. The Twelve-Factor App adds that using a different type of database in development and in production can make code that passed the tests fail in production.

First step: find the failing operation in the logs and reproduce it in testing with data of that same shape (size, empty values, characters). Synthetic data is preferable. If you need to start from real data, it may be personal data: check first with whoever is responsible for data protection in your organisation. Masking or pseudonymising it is not enough; only irreversibly anonymised data falls outside the GDPR. This is not legal advice.

Cause 3: the load and resource limits are different

Few requests in testing, many in production. In Kubernetes, a container that exceeds its CPU limit is slowed down (the system “throttles” it) and, if it exceeds its memory limit, the system may terminate it. Microsoft recommends that the test environment replicate production’s autoscaling and configuration, and testing traffic spikes and prolonged operation.

First step: look at the application’s CPU, memory and restarts in the failure window. If the limits differ between environments, make them match and repeat.

Cause 4: external dependencies, network and permissions

To move quickly, tests usually simulate the payment, the email or a third party’s service. Microsoft warns that mocking external dependencies makes tests faster and more predictable, but hides real performance problems; in addition, real network latency is not reproduced either.

First step: list everything the application calls outside itself (APIs, database, queues, DNS, firewalls), mark which ones are mocked in testing and review the timeouts of those calls.

Cause 5: it is not the same software

If you deploy with moving tags, such as :latest, you don’t know which version is running. Kubernetes advises against it in production because it is harder to know which version is running and to roll back properly; it recommends a meaningful tag and/or an immutable identifier (digest).

First step: note the exact version (tag, digest or commit) running in each environment and check that it is the same artefact. [Nubyron view] The healthy approach is to build it once and promote that same artefact.

What we can’t tell you from here

Which of the five is your cause: without your logs and metrics it cannot be stated. Start with the checks that cost nothing (causes 1 and 5) and carry on according to what the logs from the moment of the failure show. Microsoft points out that no test environment fully replicates production, and that testing in production requires safeguards, limited exposure and a rollback plan.

Sources (accessed 26 November 2026)

Google, “Monitoring Distributed Systems”, SRE book (no date on the page)
The Twelve-Factor App, “Config” (undated)
The Twelve-Factor App, “Dev/prod parity” (undated)
Kubernetes, “Resource Management for Pods and Containers” (no visible date)
Kubernetes, “Images” (no visible date)
Microsoft Learn, “Architecture strategies for performance testing” (page date: 24/06/2026)

The trade marks mentioned belong to their owners and are referred to only to identify their products.

Frequently asked questions

Does testing have to be identical to production?

Not always. Microsoft recommends matching it for critical workloads (machine type, autoscaling, cache, network, external dependencies) and, for non-critical ones, using a scaled-down version that mimics production.

Can I fix it directly in production?

Better not to touch anything without noting what you are changing and how to roll back. [Nubyron view] A live change with no record tends to add a second problem to the first.

How do I know which of the five is mine?

With the first step of each one. Compare the environments (causes 1 and 5), reproduce the failure with similar data and load (2 and 3) and review what calls third parties (4).

Next step

If you want to go through your case, you can book a 30-minute meeting on the DevOps as a Service page.

Book 30 minutes

See DevOps as a Service ↗