// guides · n8n error index

n8n HTTP Request pagination not working: endless loops, duplicates and fixes, 27 runs

Fix n8n HTTP Request pagination: requests that never stop, "The returned response was identical 5x", "'null' is not a valid URL", duplicated first pages, only one page fetched, and one item per page. 27 real runs on n8n 2.43.7.

Updated 2026-10-24 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. Use $pageCount + 1 for page numbers

    In Options → Pagination, choose Update a Parameter in Each Request and set the page parameter to {{ $pageCount + 1 }}. $pageCount starts at 0. With {{ $pageCount }}, our API treated page 0 as page 1, so the first two records came back twice and the run still succeeded. For an offset API, use {{ $pageCount * 2 }} with your page size.

  2. Don't build the next page from $request

    An expression like {{ Number($request.qs.page) + 1 }} never moves forward: $request is the node's original request, not the previous one, so every request asked for page 2 and n8n stopped with The returned response was identical 5x, so requests got stopped. Without Number() it's worse: query values are strings, so {{ $request.qs.page + 1 }} asked for page 11 and returned 0 items with no error. Use $pageCount or a value from $response instead.

  3. 'Response Is Empty' only works if the whole body is empty

    The default Complete When, Response Is Empty, stops only when the body is [], {} or empty. Most APIs wrap results like {"data":[],"page":5,"total_pages":3}, which is never empty. Our run kept requesting page 5, 6, 7 and so on: 217,874 requests in about 9 minutes, no error, until we killed it. Pick Other and write the real stop rule, like {{ $response.body.data.length === 0 }} or, to save a request, {{ $response.body.page >= $response.body.total_pages }}.

  4. Cursor and next-URL APIs need their own stop rule too

    For a cursor, set the cursor parameter to {{ $response.body.next_cursor }} and Complete When Other {{ !$response.body.next_cursor }}. With Response Is Empty instead, the last page sent an empty cursor, the API returned page 1 again, and it cycled 1, 2, 3, 1, 2, 3. For Response Contains Next URL, use {{ !$response.body.next }}: with Response Is Empty the node failed at the end with 'null' is not a valid URL. and lost every page it had fetched. A relative link fails with '/nexturl?p=2&rel=1' is not a valid URL., so prefix your base URL.

  5. Link header pagination: read the lowercase header

    For APIs that send a Link header (GitHub style), set Next URL to {{ $response.headers.link.match(/<([^>]+)>;\s*rel="next"/)[1] }} and Complete When Other {{ !($response.headers.link||'').includes('rel="next"') }}. Header names are lowercase in $response.headers. Without that stop rule, the last page had no Link header and n8n went back to page 1: 184,154 requests in about 7 minutes, again with no error.

  6. Set Limit Pages Fetched while you build

    Turn on Limit Pages Fetched with a small Max Pages while testing. It turned our endless loop into 10 requests. n8n's only built-in brake is the identical-5x error, and it does not catch pages that differ or a loop that cycles through 3 pages. Turn the limit off (or raise it) when you go live: with Max Pages 2 we got 4 of 5 records, a green run and no warning.

  7. Don't put the page in the URL as well

    With ?page=1 already in the URL plus a pagination parameter named page, n8n sent ?page=1&page=2, our API read the first one, and the run failed with the identical-5x error. Remove the page from the URL and Query Parameters. For POST APIs, set the pagination parameter Type to Body: n8n merged "page":2 into the JSON body and kept the other fields.

  8. Split pages into items, and handle 404, 429 and the full response

    A wrapped API gives one item per page with the records inside data, so add a Split Out node on data. If the API answers 404 after the last page, the node fails with The resource you are requesting could not be found; set Complete When to Receive Specific Status Code(s) 404, then filter out the extra item that holds the 404 body. A rate limit gave The service is receiving too many requests from you on page 2; the hint points to batching, but for pagination the fix is Interval Between Requests (ms) (600 ms worked). Include Response Headers and Status gives one {body, headers, statusCode} item per page, including the empty last page.

What we ran

On 24 October 2026 we ran 27 executions of the HTTP Request node (v4.2, Options → Pagination) on n8n 2.43.7 with n8n execute, against a local test API with 5 records, 2 per page. The API had the common shapes: a plain JSON array, a wrapped {data, page, total_pages} body, a cursor, a next URL, a Link header, offset and limit, a 404 after the last page, a rate limit, and a POST endpoint. We counted every request in the API's log. Real GitHub, Shopify or HubSpot APIs were not called; the shapes mirror theirs.

SetupResult
No paginationFirst page only (2 of 5 records), no warning
Plain array, page {{ $pageCount + 1 }}, Response Is Empty4 requests, all 5 records, one item per record
Same with {{ $pageCount }} (API treats page 0 as 1)5 requests, 7 items: first 2 records duplicated, success
Wrapped {data:[...]}, Response Is EmptyNever stopped: 217,874 requests in about 9 min, no error
Same with Limit Pages Fetched 1010 requests, 10 items (7 empty pages), success
Wrapped, Other {{ $response.body.data.length === 0 }}4 requests, one item per page (data array inside)
Wrapped, Other {{ $response.body.page >= $response.body.total_pages }}3 requests, no wasted request
Cursor, Other {{ !$response.body.next_cursor }}3 requests, all records (first request sends an empty cursor)
Cursor, Response Is Empty, limit 12Cycled pages 1, 2, 3 four times: 12 requests, records repeated
Next URL, Other {{ !$response.body.next }}3 requests, all records
Next URL that is relative'/nexturl?p=2&rel=1' is not a valid URL.
Next URL, Response Is Empty'null' is not a valid URL. after the last page; all pages lost
Link header with a stop rule3 requests, all 5 records
Link header, Response Is EmptyCycled back to page 1: 184,154 requests in about 7 min, no error
Offset {{ $pageCount * 2 }}, Other {{ $response.body.results.length < 2 }}3 requests, all records
Offset {{ $request.qs.offset + 2 }}Sent "02" every time: The returned response was identical 5x, so requests got stopped
Page {{ $request.qs.page + 1 }}Asked for page 11: 0 items, success
Page {{ Number($request.qs.page) + 1 }}Page 2 every time, then the identical-5x error
404 after the last page, Response Is EmptyThe resource you are requesting could not be found; all pages lost
404 after the last page, Receive Specific Status Code(s) 404Success, plus a 6th item holding the 404 body
Rate-limited API, no intervalFailed on page 2: The service is receiving too many requests from you
Same with Interval Between Requests 600 ms4 requests, all records, no 429
POST, pagination parameter Type BodyPage merged into the JSON body, other fields kept, 3 requests
Include Response Headers and StatusOne {body, headers, statusCode, statusMessage} item per page, empty last page included
Limit Pages Fetched, Max Pages 24 of 5 records, success, no warning
?page=1 in the URL plus a page parameter?page=1&page=2, then the identical-5x error
Typo {{ $response.next_cursor }} (no .body)Stopped after 1 request: 2 of 5 records, success

Good to know

What we didn't test

FAQ

Why does my n8n HTTP Request pagination never stop?

In our runs it was almost always Complete When left at Response Is Empty on an API whose body is an object like {data: [], page: 5}. That body is never empty, so n8n keeps asking. Choose Other and stop on the real signal, such as data.length === 0, no next cursor or no next link, and set Limit Pages Fetched while testing.

What does 'The returned response was identical 5x, so requests got stopped' mean?

n8n got the same response five times in a row and stopped. In our tests the page parameter wasn't changing: it was built from $request (the original request), from a string like '0' + 2, or the page was also hard-coded in the URL. Use {{ $pageCount + 1 }} for page numbers.

Why do I get duplicate items with n8n pagination?

$pageCount starts at 0. If your API treats page 0 as page 1, using {{ $pageCount }} fetches the first page twice. Use {{ $pageCount + 1 }}, or check which index your API starts at.

Why does n8n say 'null' is not a valid URL at the end of pagination?

With Response Contains Next URL, the last page returns next: null and n8n tries to open it. Set Complete When to Other with {{ !$response.body.next }} so it stops before that request.

Why does n8n return one item per page instead of one per record?

When the API wraps records in a field like data or results, each page becomes one item. Add a Split Out node on that field after the HTTP Request node.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.