Crypto
21 Sep 2026
Read 12 min
How to fix HTTP 403 error when web scraping instantly *
how to fix HTTP 403 error when web scraping and restore reliable page downloads with practical steps
What a 403 Really Means
A 403 status means the server understood your request but will not serve it. You do not lack a password (that would be 401). You are not hitting a broken page (that would be 404). The server is saying, “I see you, but I refuse.” Sites do this to stop bots, protect data, or enforce rules. Common triggers include:- Missing or fake headers like User-Agent or Referer
- No cookie or session history
- Too many requests in a short time
- Blocked IP ranges, VPNs, or data center proxies
- Bad TLS or HTTP fingerprints that do not look like a browser
- Missing CSRF or other tokens from forms or APIs
- Requests to paths blocked by robots.txt or terms of use
Quick Wins: Make Your Request Look Like a Browser
Most easy 403 fixes come from cleaning up the request. Start here before you reach for proxies or headless browsers.Send a Real User-Agent
Many sites block unknown clients. Use a current, stable browser User-Agent. Keep it consistent during a session. Do not switch it on every request.Add Common Accept and Language Headers
Real browsers send Accept, Accept-Language, and Accept-Encoding. Add them.- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- Accept-Language: en-US,en;q=0.9
- Accept-Encoding: gzip, deflate, br
Use a Referer When It Makes Sense
If you click from page A to page B, send page A as Referer. Many sites expect this flow.Keep Cookies and Sessions
Do not throw away cookies. Save them between requests. Some sites set a challenge cookie first, then allow content. Without cookies, you look like a new visitor every time, which raises flags.Honor Method, Origin, and CSRF Rules
If a form has a hidden CSRF token, read it first, then send it back with your POST. For APIs, include the right Origin and X-Requested-With headers if the site uses them.how to fix HTTP 403 error when web scraping
Use this simple plan. Move to the next step only if you still see 403 after testing.1) Start With a Browser-Like Client
- Set a realistic User-Agent and header set.
- Enable redirects. Follow 301/302/307 chains.
- Persist cookies per domain.
- Retry with exponential backoff on 429/403-with-retry clues.
2) Slow Down and Randomize
- Add a delay between requests (e.g., 1–5 seconds, random).
- Limit concurrency (e.g., 2–4 threads per domain).
- Respect crawl-delay if listed in robots.txt.
3) Rotate IPs the Smart Way
- Use residential or mobile proxies for sites that block data centers.
- Rotate IPs per session, not per request. Keep one IP for 10–20 page views.
- Avoid known bad ranges and public VPNs.
4) Fetch Tokens and Solve Flows
- Load the page that issues a CSRF or session token first.
- Parse and store the token. Send it with the next request.
- For GraphQL or JSON APIs, send the same headers your browser sends.
5) Use a Headless Browser When Needed
Some pages build content with JavaScript or run bot checks. Use a headless browser like Playwright or Puppeteer:- Enable stealth features to reduce bot signals.
- Wait for network idle or a key selector to appear.
- Mimic human actions: mouse move, small scroll, slight think time.
6) Watch Fingerprints
Modern sites check more than headers:- HTTP/2 vs HTTP/1.1 use
- TLS cipher suites and JA3 profile
- Order of headers and ALPN
Avoid Bot Blocks the Right Way
You do not need to “break” defenses. You need to behave like a good visitor.Be Gentle With Rate Limits
- Read robots.txt and the site’s terms.
- Pace requests and spread them over time.
- Cache results and avoid re-downloading unchanged pages.
Choose the Right Proxy Type
- Data center proxies: fast and cheap, but often blocked.
- Residential proxies: higher trust, better for tough sites.
- Mobile proxies: highest trust, but slow and costly.
Handle Captchas Lawfully
If you see a captcha, you are at the limit. Slow down. If solving is allowed, use a compliant service. Better yet, fix the cause: speed, headers, IP type, or missing tokens.Test, Monitor, and Iterate
You cannot fix what you cannot see. Add visibility to your scraper.Log the Full Exchange
- Record request headers, response headers, status codes, and timing.
- Store HTML samples for blocks to review patterns.
Label Errors by Type
- 403 on first request: header or IP problem.
- 403 after a few pages: rate limit or behavior issue.
- 403 on POST only: token or origin issue.
A/B Test Changes
Try one change at a time:- Only add proper headers first.
- Then add cookie jar and sessions.
- Then slow down.
- Then rotate IPs.
- Then switch to headless for hard pages.
Legal and Ethical Basics
Scrape with care.- Check the site’s terms of use.
- Respect robots.txt, even if not a law in your area.
- Do not collect personal data you do not need.
- Honor copyright. Use data only for allowed purposes.
- If the site offers an API, use it first.
Troubleshooting by Symptom
Use these quick guides to shorten your fix loop.403 Only on Assets (images, CSS, JS)
- Add Referer from the page that links to the asset.
- Send the same Host and cookies used for the page.
- Mirror the Accept and Accept-Encoding headers.
403 After Two or Three Requests
- Reduce concurrency to 1–2.
- Increase delay to 3–7 seconds.
- Keep the same IP for a small session window.
- Rotate the User-Agent less, not more.
403 on POST but GET Works
- Fetch and include CSRF or anti-bot tokens.
- Send Origin and Referer that match the site.
- Use the right Content-Type and JSON shape.
403 With a Bot Wall (e.g., Cloud-Based)
- Try a headless browser with default browser profiles.
- Use residential proxies from the same country as the site.
- Warm up: visit the home page, wait, scroll, then go deeper.
403 When Using HTTP Library but Not Browser
- Switch to HTTP/2 if the site prefers it.
- Use a TLS stack that matches Chrome or Firefox.
- Consider Playwright/Puppeteer for that domain only.
Build a Simple, Robust Flow
Here is a steady pattern that works for most sites:- Fetch robots.txt and set your crawl rules.
- Start a session with real headers and a cookie jar.
- Load the landing page and wait for any redirects.
- Extract tokens if needed. Store them.
- Crawl with delays, low concurrency, and caching.
- When blocked, back off for minutes, then resume slower.
- If blocks persist, move the domain to a browser-based scraper with residential proxies.
For more news: Click Here
FAQ
* The information provided on this website is based solely on my personal experience, research and technical knowledge. This content should not be construed as investment advice or a recommendation. Any investment decision must be made on the basis of your own independent judgement.
Contents