Screenshot API error ยท HTTP 502

Target answered an HTTP error

target_http_error

With ignore_host_errors=false, the website answered the page with an HTTP status of 400 or more, so the render failed instead of capturing the error page. target_status in the body has the status.

How to recognize it

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

HTTP/1.1 502
Content-Type: application/json

{
  "error": {
    "code": "target_http_error",
    "message": "The target website answered with HTTP status 404. Send ignore_host_errors=true to capture the page anyway."
  },
  "message": "The target website answered with HTTP status 404. Send ignore_host_errors=true to capture the page anyway."
}

Common causes

  • A URL that does not exist (404), or a page that needs a login (401, 403).
  • A server error of the website (500, 502, 503).
  • A website that answers requests from data centers with an error status.

How to fix it

  1. Check the URL, and that it loads in a browser in which you are not signed in.
  2. Leave out ignore_host_errors (it is true by default) to capture the error page; every render of a URL answers the page’s status in the X-Target-Status header.
  3. For a page behind a login, send the session with cookies, headers or authorization.

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, cookies, headers, authorization. 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