How to follow HTTP redirects with cURL

When you need to get the actual page content, the cURL follow redirect method becomes very useful. By using the curl -L <URL> command, instead of the single curl <URL>, you ensure that you visit the final page and scrape the data from there. In other cases, the website can redirect you to a location-specific page, or any other page that it decides. Here, you’ll see how to use it and how to debug potential issues.

Combined with CyberYozh proxies, you get the toolset to get the content from any page without restrictions or unwanted redirects. 

ℹ️

cURL is extremely useful when you need to perform HTTP requests quickly and automatically. Read how to authenticate websites using cURL for more information.

The tools: What proxy to select

Redirect chains often route through geo-specific or CDN endpoints, so the proxy behind your cURL request determines whether you land on the correct final page or get blocked mid-chain. 

Residential rotating proxies should be your default choice: their IP rotation is easy to control per request or per session, which is critical for web scraping and data collection workflows where each redirect hop needs a clean, trusted IP.

Proxy type

Usage for redirect-heavy tasks

Residential rotating proxies

Preferred default: controllable rotation, low block rate on multi-hop chains

Mobile LTE/5G proxies

Best for login/geo-gated redirects requiring carrier-level trust

Residential ISP proxies

Stable static IP for redirect chains needing session persistence

Datacenter proxies

Fastest, but weakest against redirect-based bot checks

The process: Use cURL follow redirect​ commands

Your basic command is:

bash
curl -L <URL>

It sets the target URL as the final destination, which must be reached even if the website redirects you to another URL, such as a location-specific page. To use with a proxy, you need to modify it a bit, adding -x (or --proxy) command with the protocol (HTTP or SOCKS5; read more about the proxy protocol selection) and proxy credentials.

bash
curl -L -x <protocol://user:password@IP:port> <URL>
⚙️

With rotating proxies, you get a gateway with credentials, accessible in your dashboard: just place it in your command, and set up the rotation there.

Use basic redirects with curl -L

Add -L to any cURL request to let it automatically follow every 3xx Location header until it reaches the final response.

bash
curl -L <URL>

Without -L, cURL stops at the first redirect and returns only the intermediate response.

Use --max-redirs to set limits

Cap the number of hops cURL will follow to prevent it from hanging on loops or excessive chains.

bash
curl -L --max-redirs 5 <URL>

Set it low (2–5) for chains you expect to be short, and higher only for known multi-step flows like login or CDN routing.

⚙️

Respecting rate limits and the website’s robots.txt is extremely important. Read about ethical web scraping to know more.

Use curl -L -v to see the redirection sequence

Add -v (verbose) to print every request and response header, including each Location hop in the chain.

bash
curl -L -v <URL>

Use this when a redirect chain behaves unexpectedly, and you need to identify exactly where it diverges.

Use curl -L -I to inspect redirect pages

Combine -I (headers-only) with -L to trace the full redirect chain without downloading page bodies.

bash
curl -L -I <URL>

This is the fastest way to confirm the final destination URL and status codes before running a full scrape.

Use curl -A to send a custom user-agent

Set a realistic user-agent string so redirect logic tied to device or browser detection resolves correctly.

bash
curl -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" <URL>
📡

Read how deploying random user-agents helps you protect your scraping pipelines and avoid restrictions.

Debug: Troubleshooting common problems

If you face any issue, don’t worry. Most of them are easily fixable. Here, we’ll explore the most common of them and how to solve them.

HTTP 302 and other response codes

With cURL redirects, you often face HTTP 3xx codes, each carrying different rules for whether the method and body are preserved. That's when you need to switch between using GET and POST methods

ℹ️

Both can be easily used with the curl function by specifying them before the URL. GET is used by default with most options, to use POST, you need to explicitly write POST before the URL.

301 Moved Permanently

The resource has a new permanent URL; some clients switch a POST to GET on follow. Use -L normally; treat the new URL as canonical for future requests.

302 Found

A legacy temporary redirect; behavior on method preservation is inconsistent across clients, so cURL may convert POST to GET. This is the most frequent issue. If you need the original method preserved, test with --post302 explicitly.

303 See Other

Always redirects to a GET request, typically after a form submission or API action completes. Expect body data to be dropped; don't rely on -L alone if you need the original payload resent.

307 Temporary Redirect

Preserves the original method and body, so a POST stays a POST. Safe to follow with -L when scraping API endpoints that redirect after submission.

308 Permanent Redirect

Same as 301 but guarantees the method is not changed. Treat as the modern, method-safe equivalent of a permanent move.

cURL doesn’t follow redirects

If curl -L seems to have no effect, the site is likely using a JavaScript or meta-refresh redirect, which cURL cannot see since it only reads HTTP headers. 

Confirm with curl -L -I first. If the status stays 200, the redirect logic is client-side and requires a headless browser instead.

⚙️

Explore Playwright and Puppeteer guides for more information about advanced web automation and scraping.

cURL 47 maximum redirects followed error

This error means cURL hit its --max-redirs limit (default is high, but loops trigger it fast). Fixes:

  1. Run curl -L -v to inspect the chain and detect a loop.

  2. Lower --max-redirs during debugging.

  3. Switch to a clean, rotating residential proxy IP. Many redirect loops are triggered by blacklisted or reused datacenter IPs being bounced by anti-bot systems.

Conclusion: Use cURL follow redirect​s

cURL redirect commands let you reach the real final page instead of stalling on an intermediate hop, using -L to follow and --max-redirs to stay safe from loops. Paired with CyberYozh residential or mobile proxies, you get consistent, unblocked access to redirect-heavy sites at scale.

Check the proxy catalog now to start.

FAQ about cURL follow redirects

How do I make cURL follow redirects?

Add the -L (or --location) flag to your command. cURL will then read each Location header and request the next URL automatically until it reaches the final page.

Why doesn't curl -L work on some sites?

The redirect may be JavaScript- or meta-refresh-based rather than an HTTP 3xx response, which cURL cannot detect since it only processes headers.

How many redirects does cURL follow by default?

cURL follows a high default number of hops, but this can be changed with --max-redirs, which also protects against infinite loops.

What does "curl: (47) maximum redirects followed" mean?

It means cURL hit its redirect limit, usually due to a loop or a site repeatedly bouncing the request, often triggered by a flagged IP.

How do I use cURL with a proxy and follow redirects at the same time?

Combine -L with -x protocol://user:password@IP:port; cURL will route every hop of the redirect chain through that proxy.

Does cURL follow 302 redirects automatically?

Only with -L enabled; without it, cURL stops at the first 302 response and does not request the new URL.

How do I stop cURL from following redirects?

Simply omit -L, or set --max-redirs 0 if you want to confirm the flag isn't accidentally set elsewhere.

Does a redirect change my request from POST to GET?

It depends on the status code: 301/302 may switch to GET on some clients, while 307/308 always preserve the original method and body.

How do I see the full redirect chain without fetching the page body?

Use curl -L -I to print only headers and status codes for every hop, revealing the final destination quickly.

Which proxy type works best for redirect-heavy scraping?

Residential rotating proxies are recommended by default because they combine controllable IP rotation with high acceptance on redirect and anti-bot checks.