Skip to content

JMeter 401 403 After Recording

Fix JMeter 401 and 403 after HTTP(S) recording: Cookie Manager, CSRF correlation, expired tokens, Header Manager scope, and CSV users. Symptom and fixes.

Difficulty
intermediate
Guide type
troubleshooting
Estimated read time
7 min read
Last verified version
Verified JMeter 5.6
  • Recording in the browser works and samplers appear under the Recording Controller
  • Replay in JMeter returns 401 Unauthorized or 403 Forbidden on login-protected steps
  • First sampler may work; later calls fail
  • Or all calls fail after the recorded session cookie/token expires

This is one of the most common post-recorder failures (HTTP recorder, best practices).

CauseDetail
Missing Cookie ManagerSession cookies from Set-Cookie not stored per thread (web test plan)
Hard-coded CSRF / viewstate / nonceValues from the recording are stale (correlation)
Hard-coded Bearer / session tokenJWT expired; need extract + Header Manager (JWT/OAuth)
Header Manager scope wrongAuthorization not applied to the failing sampler
Same user / concurrency rulesApp rejects parallel sessions for one account
Include/exclude left noise outLogin API calls never recorded
HTTPS recorder cert issues during captureIncomplete journey recorded (unknown_ca per best practices)
  1. Replay with 1 thread, View Results Tree on; find the first 401/403.
  2. Add an HTTP Cookie Manager at Test Plan or Thread Group level.
  3. Compare the failing request to the previous response: look for tokens in HTML/JSON/headers.
  4. Add JSON or Regular Expression Extractor; replace hard-coded values with \${var} (correlation guide, Regex Extractor Builder).
  5. For APIs: extract access_token, set header Authorization to Bearer `\${accessToken}` (JWT/OAuth).
  6. Use CSV Data Set for unique users when the app requires it (best practices multi-user pattern).
  7. Assert login success (status + body) so silent auth failure does not flood later steps.
  8. Disable Tree, run CLI, confirm error % on the dashboard.
ResourceUse when
CorrelationExtract dynamic fields
Regex Extractor BuilderDraft regex from a response body
HTTP recorderCapture and cleanup
JWT / OAuth / SSOToken APIs
API load testingAssertions and headers

Why did recording work if replay returns 401?

Section titled “Why did recording work if replay returns 401?”

Recording used your live browser session. Replay is a new session unless cookies and tokens are correlated for each virtual user.

Section titled “Do I need extractors if I only use Cookie Manager?”

Cookies often cover classic server sessions. CSRF tokens, hidden fields, and Bearer tokens still need extractors.

Yes. Correlate anti-forgery tokens and required headers; match the browser’s security headers when they are mandatory.

On this page