Steps
Use $pageCount + 1 for page numbers
In Options → Pagination, choose Update a Parameter in Each Request and set the page parameter to
{{ $pageCount + 1 }}.$pageCountstarts 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.Don't build the next page from $request
An expression like
{{ Number($request.qs.page) + 1 }}never moves forward:$requestis the node's original request, not the previous one, so every request asked for page 2 and n8n stopped withThe returned response was identical 5x, so requests got stopped. WithoutNumber()it's worse: query values are strings, so{{ $request.qs.page + 1 }}asked for page 11 and returned 0 items with no error. Use$pageCountor a value from$responseinstead.'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 }}.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.Link header pagination: read the lowercase header
For APIs that send a
Linkheader (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.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.
Don't put the page in the URL as well
With
?page=1already 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":2into the JSON body and kept the other fields.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 ondata. If the API answers 404 after the last page, the node fails withThe 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 gaveThe service is receiving too many requests from youon 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.
| Setup | Result |
|---|---|
| No pagination | First page only (2 of 5 records), no warning |
Plain array, page {{ $pageCount + 1 }}, Response Is Empty | 4 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 Empty | Never stopped: 217,874 requests in about 9 min, no error |
| Same with Limit Pages Fetched 10 | 10 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 12 | Cycled 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 rule | 3 requests, all 5 records |
| Link header, Response Is Empty | Cycled 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 Empty | The resource you are requesting could not be found; all pages lost |
| 404 after the last page, Receive Specific Status Code(s) 404 | Success, plus a 6th item holding the 404 body |
| Rate-limited API, no interval | Failed on page 2: The service is receiving too many requests from you |
| Same with Interval Between Requests 600 ms | 4 requests, all records, no 429 |
| POST, pagination parameter Type Body | Page merged into the JSON body, other fields kept, 3 requests |
| Include Response Headers and Status | One {body, headers, statusCode, statusMessage} item per page, empty last page included |
| Limit Pages Fetched, Max Pages 2 | 4 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
- For GraphQL APIs, variables built by hand often break: see n8n GraphQL node not working.
- Status and connection errors from the same node (401, 403, 404, ECONNREFUSED, certificates): n8n HTTP Request node errors. Turning one item per page into one item per record: Split Out, Aggregate and Summarize. Paging inside a loop instead: Loop Over Items.
- Every error message we reproduced is in the n8n error message index.
- Scraping each page you fetched? See n8n HTML Extract not working.
What we didn't test
- Live third-party APIs, predefined credential types with pagination, n8n Cloud, and very large pages (memory limits).
Start from a working agent
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
- n8n Loop Over Items not working? 15 tests of what really happens
- n8n XML node not working: parse errors, one item vs array, attributes and Split Out, 39 runs
- n8n Respond to Webhook not working: empty body, Invalid JSON, 28 runs
- n8n next node not running? Empty output and Always Output Data, 18 tests
- Get notified when a website changes: free alerts in Discord or Telegram
New guides
- GitHub release notifications in Slack (any public repo, stable releases only)
- Send RSS feeds to Slack with a keyword filter (free, incoming webhook)
- Forward emails to a Slack channel (Gmail, Outlook, any IMAP), free with an incoming webhook
- n8n Google Sheets Trigger not working: not firing, activation errors and fixes