403 Forbidden means a server understood your request but refused to fulfill it. To fix 403 Forbidden when web scraping, first identify whether the refusal comes from the origin, a CDN or WAF, or your proxy. Compare the same request under controlled conditions, then correct permissions, session handling, server rules, or routing only where evidence supports that change. RFC 9110, section 15.5.4: 403 Forbidden.
Jump to the triage ladder, platform fixes, or verification checklist.
Key Facts
- Do not automatically retry a 403 with unchanged credentials. Investigate first; retry only when a supported correction or the service’s instructions justify it. If access is not authorized, request access or stop.
- A 403 status alone does not identify the component that refused access.
- A successful browser comparison does not prove that fingerprinting caused the scraper’s failure.
- A route-dependent result does not establish IP reputation as the cause.
- 429 responses can include
Retry-After, but that header is optional. - Proxies cannot grant missing permissions or repair origin configuration.
What does 403 Forbidden actually mean in scraping?
A 403 identifies a refusal, not its underlying policy. Credentials can be insufficient, but the reason can also be unrelated to credentials. Avoid automatically repeating the request with unchanged credentials. RFC 9110, section 15.5.4: refusal reasons and retries.
Capture the failing request’s actual response before editing your scraper. For an authorized GET request, replace the example address with the affected URL:
curl --version
curl -i --max-time 30 'https://example.com/'
The -i option displays response headers with the body; --max-time limits the transfer duration. This command does not automatically follow redirects. Inspect the first response before adding --location. See the curl manual for --version, -i, --max-time, and --location.
The example address returned this status line:
HTTP/2 200
Your affected URL may return a different status. Read its response in three parts: the status line, headers before the blank line, and the body afterward. The body may explain an authorization failure or identify a policy, but a generic error page alone cannot establish the cause.
Keep the UTC timestamp, curl version, operating system, matching command, and direct or proxy route with your capture. Preserve the response explanation and request identifier. Remove cookies, tokens, and personal information before sharing it, and identify which fields you redacted. Use the status-code reference to classify other responses separately.
How do you diagnose 403 Forbidden with a 5-step triage ladder?
Use the ladder to narrow the cause while keeping the request comparable. Stop once evidence identifies a corrective action; completing every comparison is unnecessary.
Step 1: Capture evidence. Record UTC time, method, URL, status, redirect sequence, response explanation, and request IDs. Label the client, account state, route, and recent request pace. Keep sensitive captures restricted and prepare a sanitized version for support.
Step 2: Check authorization. Confirm the intended endpoint and documented access requirements. Compare anonymous and authorized requests only where you have access. If both fail, retain multiple hypotheses: permission, routing, or a server rule. Do not infer that the page is private from that result alone.
Step 3: Isolate the route. Where permitted, compare direct and proxy requests while holding method, endpoint, client, and account state constant. A difference establishes route dependence in that comparison, not the emitting component or its reason.
Verify the effective proxy configuration before comparing routes. Environment proxy settings and bypass rules can change the route without an obvious code change. Record intended and observed routes privately, keeping authentication, redirects, and request headers comparable. For an approved direct curl comparison, --noproxy '*' bypasses configured proxies for every hostname; it does not disable a VPN or transparent network intermediary. See the curl proxy bypass documentation.
If a VPN is already in use, record it as part of the route. Compare approved routes only where permitted; a changed outcome does not establish permission to circumvent a restriction.
Step 4: Compare clients. Compare the working browser request with the failing scraper request. Check the final URL, method, authentication state, cookies, and redirects first. Browser success is a lead to investigate, not proof that changing a user agent or TLS behavior will solve it.
Step 5: Reduce pace. Pause the job, then make a limited, authorized comparison at lower concurrency. Record 403 and 429 bodies separately. A quieter run succeeding suggests a pacing hypothesis; correlate it with policy events before treating it as established. See API rate limiting for pacing design.
Use the same evidence checklist for Scrapy, Cheerio-based workflows, jsoup, and Puppeteer. For pages naming DataDome, HUMAN/PerimeterX, Kasada, or Imperva, record the branding as a clue and ask the owner to confirm the enforcing component and rule.
Who blocked the request: origin, WAF/CDN, or proxy?
Headers and branding are clues. Ask the operator to match the timestamp and request ID against edge events, origin access and error logs, and proxy logs. An origin entry alone does not prove the origin generated the final response; compare the recorded status and downstream handling.
If you cannot access logs, send the owner a compact evidence packet and describe the attribution as uncertain. Include the request time, sanitized URL, method, response identifier, and the single variable that changed.
| Symptom | Check | Meaning | Fix |
|---|---|---|---|
| Browser works, Requests fails | Compare session, URL, method, and redirects. | Client or session difference; not proof of fingerprinting. | Reproduce documented authentication and the intended endpoint. |
| Proxy route alone fails | Compare routes and correlate logs. | Route-dependent refusal; emitter remains uncertain. | Correct confirmed proxy policy or configuration, or request allowlisting. |
| Directory fails, file works | Inspect index configuration and the error entry. | Possible index or access rule. | Restore intended index selection or narrowly scoped access. |
| Cloudflare page | Correlate Ray ID and timestamp with events; check hostname and TLS SNI for early unstyled responses. | Possible edge rule; missing events do not exclude Cloudflare. | Correct the confirmed rule or hostname/SNI mismatch. |
| 403 and 429 alternate | Record pace, bodies, and rule events. | Multiple policies may apply. | Reduce load and diagnose each response separately. |

Which 403 Forbidden fixes work for each platform?
Apply the smallest change supported by the evidence. Separate what you control from what requires the website or infrastructure owner.
| Role | Useful action | Escalation |
|---|---|---|
| Visitor | Check URL, account, and a fresh session. | Send the owner the error and timestamp. |
| API developer | Verify credentials, scopes, and endpoint. | Ask the API owner to confirm authorization. |
| Server owner | Match logs to access, index, and WAF rules. | Contact hosting or security support. |
| Scraper operator | Compare session, route, client, and pace. | Request approved access or allowlisting. |
Python Requests
Use a Session to preserve cookies across related requests. Requests exposes redirect history and timeout controls; Beautiful Soup parses retrieved documents and does not perform authorization. See the Requests Session documentation and Beautiful Soup documentation.
With Requests installed, this example prints statuses and body lengths without exposing response bodies or credentials. Replace the example URL and establish required authentication through the site’s documented workflow.
import requests
url = "https://example.com/"
with requests.Session() as session:
try:
response = session.get(
url, timeout=(5, 20), allow_redirects=True
)
for hop, item in enumerate(response.history + [response]):
print({
"hop": hop,
"status": item.status_code,
"body_bytes": len(item.content),
})
except requests.RequestException as error:
print({"error_type": type(error).__name__})
This is a limited diagnostic summary. Inspect redirect destinations, response headers, and the refusal explanation privately. A proxy connection failure can produce an exception instead of a target-server response; the exception class alone does not establish which policy caused it. See the Requests adapter implementation.
The timeout=(5, 20) tuple sets connect and read timeouts, not a total execution deadline. See Requests timeout guidance.
For a proxy comparison, pass an explicit per-request proxies argument for the relevant destination scheme. This avoids environment settings overriding session.proxies. An empty dictionary does not universally guarantee direct access. Check effective environment settings and bypass rules, as explained in the Requests proxy documentation.
Cloudflare
Cloudflare documents origin refusals and edge-generated 403 responses, including unstyled responses generated before domain configuration loads. An unbranded page is therefore not conclusive origin attribution.
Cloudflare says these early unstyled responses are not logged. A missing Security Events entry does not exclude Cloudflare. Check whether the requested hostname and TLS Server Name Indication (SNI) match; a mismatch is one documented cause. See Cloudflare Error 403.
Ask the owner to correlate the Ray ID and timestamp with the action and rule in Security Events. Sampled events are not a complete request ledger. An administrative-rules refusal message is a clue, not a unique diagnosis. Adjust the confirmed rule narrowly rather than disabling protection globally.
nginx
For a directory-only failure, inspect index selection and effective access rules. nginx checks allow and deny rules in sequence until the first match. See the access module documentation.
If /docs/index.html succeeds but /docs/ fails, verify that the intended index directive selects that file. Check which location handles the resulting internal redirect. See the index module documentation.
If logs report a filesystem permission problem, inspect the worker identity, parent-directory traversal access, and target-file access. Restore intended permissions instead of applying blanket chmod changes. Validate and reload the intended configuration using the nginx administration guidance.
Apache
Verify the effective DirectoryIndex list and Require rules for the directory. In .htaccess, DirectoryIndex uses the Indexes override category, while Require uses AuthConfig. Check the applicable override permissions. See DirectoryIndex and Require.
A directive disallowed in .htaccess can cause a server error instead of repairing the original refusal. Consult Apache’s troubleshooting guidance. Restore the intended index or correct the authorization condition identified in logs. Do not enable directory listing or grant access indiscriminately.
Browser, Windows, Safari/iPhone, Chrome/Android
Check the exact URL and intended account first. Compare a private session, recording whether it is anonymous or signed in. Consider clearing stored site data if the evidence points to session state.
On Windows, use the same checks. If necessary, remove only the affected site’s cookies through your browser’s controls. See Google Chrome desktop instructions.
In Chrome on Android, open the affected website, then choose More > Site controls > Cookies. Next to the stored data, tap Delete. See Google’s single-site cookie instructions.
On iPhone, Apple’s procedure uses Settings > Apps > Safari > Advanced > Website Data > Remove All Website Data. This removes all website data, not just data for the failing site, and can sign you out of websites. See Apple’s instructions.
For a controlled network comparison, keep browser and account state unchanged. Contact the owner if access remains refused. Reinstalling the browser is not a useful first diagnostic step.
Which exit type should you use once you know the cause?
Choose an exit only when evidence supports a routing requirement. A route change cannot grant permissions or repair origin configuration.
Compare candidate routes against the owner’s access requirements. Do not assume residential, mobile, or datacenter traffic will be accepted solely because of the address category.
| Routing choice | Use when | Avoid when |
|---|---|---|
| Existing direct or datacenter route | It meets approved access requirements. | Logs identify a policy excluding it. |
| Residential or mobile route | An authorized geographic or network requirement justifies evaluation. | You are guessing from the 403 alone. |
| Sticky session | The permitted workflow needs exit continuity. | You expect continuity to override missing permission. |
| Rotation | Independent authorized requests permit changing exits. | The workflow requires a stable route. |
DataImpulse offers residential, mobile, and datacenter proxies, with rotating or sticky sessions. Use the rotating versus static proxies guide to assess continuity requirements before changing session routing.
What mistakes make a 403 worse?
Stop the retry loop and preserve a baseline before experimenting. Each comparison should answer one question.
- Blind retries: repeating the same refusal adds traffic without testing a hypothesis.
- Simultaneous changes: replacing credentials, route, and client together prevents useful attribution.
- Rotating an authenticated workflow: changing exits adds another variable to session debugging.
- Assuming every success is valid: inspect returned content before sending it to your parser.
- Discarding evidence: retain failing response details so the owner can locate the event.
Configure retry decisions by response class instead of retrying every failure. The Python Requests retries guide covers the broader workflow.
How does 403 differ from 401, 407, 429 and Cloudflare 1015?
| Code | Meaning | Diagnostic header | Next action |
|---|---|---|---|
| 401 | The request lacks valid authentication credentials. RFC 9110. | WWW-Authenticate |
Inspect the challenge and supply documented credentials for an authorized account. |
| 403 | The request was understood but refused. RFC 9110. | No mandatory diagnostic header. | Inspect the explanation and policy evidence; avoid unchanged automatic retries. |
| 407 | Proxy authentication is required. RFC 9110. | Proxy-Authenticate |
Check proxy credentials using the 407 troubleshooting guide. |
| 429 | Too many requests were sent in a given time. RFC 6585. | Retry-After, when present. |
Honor Retry-After when supplied and reduce volume according to service policy. |
| Cloudflare 1015 | A Cloudflare-specific rate-limiting error, not a standard HTTP status. Cloudflare documentation. | Inspect Retry-After if supplied. |
Pause requests and confirm the limit with the owner. See the Cloudflare 1015 guide. |
How do you verify the 403 fix?
Repeat the original authorized request with only the intended correction. Confirm expected content, endpoint, account context, and redirect destination. A 200 response containing a login page is not the desired result.
Ask the owner to confirm the relevant rule or error condition changed. Check a short permitted sequence for session stability before restoring workload gradually. Record the correction, timestamp, client version, and sanitized before-and-after evidence. If the failure returns, pause instead of layering changes onto an uncertain fix.
When is a 403 the final answer?
Stop when the owner confirms that your account or automation is not authorized. Request access, an approved API, or another permitted delivery method.
A login page alone is not a reason to abandon an authorized integration. Equally, a public-looking page does not establish that every automated access method is approved. Resolve the access question with the owner.
When attribution remains uncertain, pause collection and escalate with evidence. A 403 does not establish a permanent ban or a site-wide outage. Treat the refusal as unresolved until the responsible operator explains it.
Frequently Asked Questions
What does 403 Forbidden mean when scraping?
It means the request was understood but refused. The status alone does not identify whether the decision came from the application or an intermediary, so inspect the response explanation and matching logs.
How do I fix a 403 when scraping?
Start with one reproducible failing request and confirm its access requirements. Compare session, route, client, and pace separately, then verify the smallest correction supported by the results.
Why do I get 403 with a browser user agent?
Changing the User-Agent header does not establish that your request matches the successful browser request. Compare authentication state, destination, method, and redirects before attributing the difference to fingerprinting.
Does changing IP fix a 403?
It can change the outcome of a route-dependent refusal, but it does not explain the policy behind it. Use a controlled comparison and ask the owner to confirm the cause before adopting rotation.
What is the difference between 403 and 429?
403 reports refusal; 429 explicitly reports excessive request volume. A 429 may include Retry-After, while a 403 alone offers no reliable waiting period.
Should I use a headless browser to avoid 403s?
Use one when the authorized workflow requires browser execution, after checking simpler request differences. Browser success is useful comparison evidence, but it does not prove why another client failed or guarantee continued access.
Last updated: November 18, 2026.
