Screenshot API error · HTTP 502

Bot challenge or block page

target_blocked

With ignore_host_errors=false, the website showed a bot challenge, block or CAPTCHA page instead of its content, so the render failed instead of capturing that page. blocked_by in the body names the vendor: cloudflare, akamai, perimeterx, datadome, imperva, aws_waf, kasada, sucuri, vercel, or captcha for a CAPTCHA wall.

How to recognize it

The API answers with status 502 and a JSON body with the message and the error.code target_blocked, for example:

HTTP/1.1 502
Content-Type: application/json

{
  "error": {
    "code": "target_blocked",
    "message": "The target website answered with a bot challenge or block page (cloudflare) instead of the page. Send ignore_host_errors=true to capture it anyway."
  },
  "message": "The target website answered with a bot challenge or block page (cloudflare) instead of the page. Send ignore_host_errors=true to capture it anyway."
}

Common causes

  • Bot protection of the website that challenges or blocks browsers from data centers.
  • A CAPTCHA wall in front of the page.
  • A challenge that did not let the browser through in time: the page is judged as it is when it would be captured, after the waits and the delay.

How to fix it

  1. Leave out ignore_host_errors (it is true by default) to capture the page as it is; the X-Blocked-By header of the response still names the vendor.
  2. A longer delay, or wait_for_selector with an element of the real content, gives a challenge that passes by itself time to finish.
  3. Loading the page from another country with ip_country_code, or through your own proxy, may get past the block.

Billing

Not billed: a request answered with this error does not count against your quota. One exception: when an evaluate step of actions or the scripts ran in the page before the render failed, it is billed as one request, because that code could read the page, unless the failure is ours.

Related parameters

ignore_host_errors, delay, wait_for_selector, ip_country_code, proxy. Each is described in the take endpoint reference.

Every response carries an X-Request-Id header. If this page does not explain the error, write to support@screenshotbase.com with that id. All statuses: status codes.

Other API errors

Screenshot API

Take screenshots from your code

screenshotbase renders any website in a real browser and returns the image: full page or viewport, any device size, retina, from 100+ countries, with cookie banners and ads hidden.

/v1/take documentation Screenshot API All documentation

300 free screenshots every month. No credit card required.

GET https://api.screenshotbase.com/v1/take?url=https://example.com&full_page=true

# Response: the image (PNG, JPG, WebP, AVIF or GIF)
curl -G "https://api.screenshotbase.com/v1/take" \
  --data-urlencode "url=https://example.com" \
  -d viewport_width=1280 -d viewport_height=800 \
  -d format=png \
  -H "apikey: YOUR-API-KEY" \
  -o screenshot.png

More free tools

Start using our Screenshot API for free today!

Get 300 requests / month for free