Coding⏱️ 4 min read📅 2026-06-11

How to Fix: How to use wget to download HTTP error pages?

Learn how to download HTTP error pages with wget.

Quick Answer: Use the -r option with wget to recursively download all files, including those with HTTP errors.

The issue of wget stopping on HTTP error pages can be frustrating for users who need to download and analyze error pages for debugging or research purposes. This problem affects anyone using wget to download web content, including developers, researchers, and system administrators.

This issue is particularly problematic when working with large websites or dealing with frequent HTTP errors. In such cases, manually navigating through each error page can be time-consuming and tedious. Fortunately, there are workarounds that can help overcome this limitation.

🔍 Why This Happens

  • The primary reason wget stops on HTTP error pages is due to its built-in mechanism for handling HTTP errors. By default, wget checks the HTTP status code returned by the server and stops downloading if it's not a successful response (200-299). This is a security feature designed to prevent wget from downloading potentially malicious content.
  • An alternative reason for this issue is that wget may be configured to only download files with specific extensions or mime types. If an error page does not match these criteria, wget may not consider it worth downloading, even if the content is still valuable.

🛠️ Step-by-Step Verified Fixes

Enabling verbose mode and setting the --save-headers option

  1. Step 1: To enable verbose mode in wget, use the -v flag followed by the URL you want to download. For example: wget -v https://example.com/error-page.html. This will display detailed information about each HTTP request and response, including any error messages.
  2. Step 2: Next, set the --save-headers option using the -H flag. This tells wget to save the HTTP headers for each page it downloads, which can include valuable information about the server's configuration and any error responses. For example: wget -v -H https://example.com/error-page.html
  3. Step 3: By enabling verbose mode and saving the HTTP headers, you can get a better understanding of what's happening behind the scenes when wget encounters an HTTP error page.

Using the --convert-links option with the --save-headers flag

  1. Step 1: Another approach is to use the --convert-links option in combination with the --save-headers flag. This tells wget to convert any relative URLs on the error page to absolute URLs, which can make it easier to download and analyze the content. For example: wget -v --convert-links -H https://example.com/error-page.html
  2. Step 2: By using these options, you can get wget to save the full URL of each error page, including any redirects or changes made by the server.

💡 Conclusion

In conclusion, wget's built-in mechanism for handling HTTP errors can be limiting when working with error pages. However, by enabling verbose mode and setting the --save-headers option, or using the --convert-links option with the --save-headers flag, you can overcome this limitation and download valuable information about each error page.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions