Next Practical Step
Diff the failing sampler against the browser’s DevTools request, add the missing headers and Cookie Manager, then correlate any stale tokens before replaying with one thread.
Fix the classic JMeter problem: requests work in a browser but fail in JMeter. Missing headers, cookies, redirects, correlation, and JavaScript gaps.
The application works perfectly in a browser, but the same requests in JMeter fail with:
Response code: 401 / 403 / 404 / 500empty response bodies, redirects that never land, or assertion failures. Recorded scripts replay once and then fail on every subsequent run.
Browsers do far more than send the URL: they attach a full header set, manage cookies, follow redirects, execute JavaScript that fires extra requests, and carry fresh dynamic tokens. A replayed JMeter script does none of that automatically. Find which of these the failing request depends on and add it explicitly.
| Cause | Typical Error | Why it happens |
|---|---|---|
| Missing request headers | 403 or 400 | The server or WAF checks User-Agent, Accept, Origin, or custom headers the browser sends but the script omits |
| No Cookie Manager | 401 or lost session | Sessions ride cookies; without a Cookie Manager each request arrives stateless |
| Uncorrelated dynamic values | 401, 403, 400 | CSRF tokens, session IDs, or bearer tokens from the recording are stale |
| Redirect handling mismatch | Redirect loops or 302 chains | Follow Redirects and Redirect Automatically behave differently, and one is often disabled |
| JavaScript-driven flows | Missing requests entirely | SPAs fire API calls from JavaScript, which JMeter never executes |
| URL encoding differences | 400 or 404 | Special characters in parameters encode differently between browser and sampler |
Open the browser’s Network tab, perform the action manually, and inspect the successful request. Compare, field by field against the JMeter sampler:
User-Agent, Accept, Content-Type, Origin, and any custom security headers).Add the missing pieces to the sampler, then re-run one thread.
Add an HTTP Header Manager at the test plan or thread group level for global headers, or under a single sampler for request-specific ones. Replicate only what the server actually inspects; there is no need to copy every browser header.
Sessions break without one. Add an HTTP Cookie Manager to each thread group. Keep the default “clear cookies each iteration” behavior unless the scenario explicitly models a returning user with a persistent session.
Extract tokens from the response that provides them and pass them into the next request:
The Correlation & Dynamic Values guide covers the patterns in depth, and HTTP 401/403 after recording covers the auth-specific variants.
In the sampler, Follow Redirects (HttpClient implementation) hands redirects to JMeter’s logic and records the final response, while Redirect Automatically replays them at the protocol level with fewer hooks. Enable exactly one per sampler, never both, and inspect the redirect chain in DevTools to know how many hops to expect.
JMeter does not execute JavaScript. For SPA flows:
API Load Testing shows how to structure these protocol-level tests.
| Resource | Use when |
|---|---|
| HTTP 401/403 after recording | Auth failures dominate the replay |
| Correlation & Dynamic Values | Tokens and session IDs need extraction |
| HTTP Recorder | Capturing browser traffic cleanly in the first place |
| Extractor Default Value | Extractors return NOT_FOUND during correlation |
JMeter is a protocol-level tool: it sends and receives HTTP requests without rendering pages or running scripts. Any request a browser fires from JavaScript must be discovered in DevTools and scripted as an explicit HTTP Request.
Only the ones the server or WAF inspects. Start with User-Agent, Accept, Content-Type, and any custom security or anti-bot headers visible in DevTools, then add more only while failures persist.
Recording captures tokens and cookies that expire after the first use. Add a Cookie Manager and correlate CSRF tokens, session IDs, and bearer values so each virtual user gets fresh ones.
Yes, but at the API level. Identify the HTTP calls the SPA makes behind its UI, script them in order, and treat the browser as a reference for the request sequence rather than as something to emulate.