Troubleshooting of HTTP errors: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 2: Line 2:


HTTP status code
HTTP status code
{{LanguageSwitcher | content = [[Troubleshooting of HTTP errors | EN]], [[Troubleshooting of HTTP errors in Mandarin | 漢字]] }}


__TOC__
__TOC__


== 400 Bad Request ==
== Troubleshooting HTTP Status Errors ==
 
=== 400 Bad Request ===
 
Root cause: The request itself is malformed. According to the spec, this means "the server cannot or will not process the request due to something perceived to be a client error" — such as invalid syntax, incorrect request message framing, or deceptive request routing.


Root cause of 400 Bad Request. HTTP Error 400. The request is badly formed.
Possible fix:
* "the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing)"<ref>[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 400 Bad Request - HTTP | MDN]</ref>
* Review and correct the request headers


Possibile solution:
=== 403 Forbidden ===
* Modify the request headers


== 403 Forbidden Error ==
See: [[How to fix the 403 forbidden error]]


[[How to fix the 403 forbidden error]]
=== 404 Not Found ===


== 404 File Not Found ==
Fix: Verify that the URL is correct. For more details, see
[[404 Not Found | 找不到網頁的可能解決方法]]
[[404 Not Found]], possible solutions for pages not found".


== 405 Method Not Allowed Error ==
=== 405 Method Not Allowed ===
解決方法:檢查存取的文件或資源支援呼叫使用的 HTTP protocol <ref>[https://dotblogs.com.tw/cotton/2018/03/01/132336 使用Http Post呼叫api卻收到405 method not allowed | 攻城獅的學習筆記 - 點部落]</ref>,例如限制使用 POST ,卻使用 GET 存取。


== 415 Unsupported Media Type ==
Fix: Confirm that the target resource supports the HTTP method you're using. For example, the endpoint may only accept POST requests while you're sending a GET request.


解決方法:「於請求中設置的 {{kbd | key=Content-Type}} 或 {{kbd | key=Content-Encoding}} 或對資料的直接訪問」。參考資料:[https://developer.mozilla.org/zh-TW/docs/Web/HTTP/Status/415 415 Unsupported Media Type - HTTP | MDN]
=== 414 Request-URI Too Large ===
 
Fix: Switch from GET to POST so the data is sent in the request body instead of the URL.
 
=== 415 Unsupported Media Type ===
 
Fix: Explicitly declare the correct Content-Type or Content-Encoding in the request, or access the data directly. For instance, when calling a RESTful API, this error can often be resolved by adding the following header:


例如:RESTful API 遇到該錯誤,可能解決方式是 HTTP Headers 加入
<pre>
<pre>
Content-Type: application/json
Content-Type: application/json
</pre>
</pre>


== 429 Too Many Requests ==
=== 429 Too Many Requests ===
原因:
* 太頻繁存取網站資源


解決方法:
Root cause:
* 調整存取頻率
* The client is hitting the website or API more frequently than the service allows.
* 如果是存取網路服務 API,請閱讀文件了解 API 本身的存取頻率限制 (Rate Limits)


參考資料
Fixes:
* [https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 429 Too Many Requests - HTTP | MDN]
* '''Throttle your requests''': Add or increase a delay between requests based on your usage pattern and the service's limits (e.g., pause 1 second between calls).
* '''Check the API rate limits''': Consult the provider's documentation for limits such as Requests Per Minute (RPM) or Requests Per Day (RPD), and find out whether you can request a higher quota.
* '''Use exponential backoff''': Detect HTTP 429 responses in your
  application, then retry with progressively longer delays (e.g., 2s → 4s → 8s) until the request succeeds or a maximum retry count is reached.


== 502 Bad Gateway ==
=== 502 Bad Gateway ===
原因:
* 因為是網路設備間發生錯誤,使用者並無法直接處理<ref>[https://hostingpill.com/zh-TW/502%E9%8C%AF%E8%AA%A4%E7%9A%84%E7%B6%B2%E9%97%9C/ 什麼是502 Bad Gateway錯誤以及如何解決(輕鬆修復指南)]</ref>。


解決方法:
Cause:
* [https://zh.wikipedia.org/zh-tw/Help:%E7%BB%95%E8%BF%87%E6%B5%8F%E8%A7%88%E5%99%A8%E7%BC%93%E5%AD%98 繞過瀏覽器快取],瀏覽器重新整理頁面
* A failure between upstream network devices/servers — not something the end user can fix directly.
* 過一陣子再重新連線


參考資料
Fixes:
* [https://developer.mozilla.org/zh-TW/docs/Web/HTTP/Status/502 502 Bad Gateway - HTTP | MDN]
* Hard-refresh the page to bypass the browser cache
* Wait a moment and try again


== Error 1020: Access Denied ==
=== Error 1020: Access Denied ===
* [https://www.affde.com/zh-TW/error-1020-access-denied.html 了解如何解決錯誤 1020 訪問被拒絕以使您的網站重新上線 - Affde營銷]
* See the linked guide on resolving Error 1020 (Access Denied) to restore access to your website.


<pre>
== HTTP Cats or Dogs ==
Content-Type: application/json
</pre>


: https://http.cat/200.jpg
<div style="zoom: 0.4;">
: From [https://http.cat/ HTTP Cats]
https://http.cat/200.jpg
</div>
From [https://http.cat/ HTTP Cats]


Related websites
Related websites:
* [https://httpstatusdogs.com/ HTTP Status Dogs]
* [https://httpstatusdogs.com/ HTTP Status Dogs]
== Other possible root causes ==
* CDN (Content delivery network)
== Mock HTTP status error page tools ==
The testing sites that can return 500 and various other HTTP status codes on demand
* [https://the-internet.herokuapp.com/status_codes The Internet]<ref>[https://stackoverflow.com/questions/24736134/is-there-a-website-that-returns-500-and-other-http-response-codes-for-testing httpresponse - Is there a website that returns 500 (and other) HTTP response codes for testing? - Stack Overflow]</ref>
* [https://httpstatus.io/ httpstatus.io]: A bulk checker for HTTP status codes, headers, and redirects, which also offers mock endpoints, e.g. [https://mock.httpstatus.io/500 500]
* [https://www.postman.com/postman/published-postman-templates/documentation/ae2ja6x/postman-echo Postman Echo]: A request/response testing service with status code endpoints, e.g. [https://postman-echo.com/status/500 500]


== Related pages ==
== Related pages ==


* [[Troubleshooting of curl errors]]
* [[Troubleshooting of curl errors]]
* [[Test connectivity for the web service]]


== References ==
== References ==
Line 77: Line 95:
{{Template:Troubleshooting}}
{{Template:Troubleshooting}}


[[Category:Programming]]
[[Category: Web server]] [[Category:Programming]] [[Category:Web scraping]]
 
[[Category:Web scraping]]

Latest revision as of 16:49, 11 June 2026


icon_scale_pencil.png This article "Troubleshooting of HTTP errors" is still being written. If there are any incomplete parts, you are welcome to directly edit them. 這篇文章「Troubleshooting of HTTP errors」內容還在撰寫中,如果有不完整的部分,歡迎你直接動手修改


HTTP status code

🌐 Switch language: EN, 漢字


Troubleshooting HTTP Status Errors[edit]

400 Bad Request[edit]

Root cause: The request itself is malformed. According to the spec, this means "the server cannot or will not process the request due to something perceived to be a client error" — such as invalid syntax, incorrect request message framing, or deceptive request routing.

Possible fix:

  • Review and correct the request headers

403 Forbidden[edit]

See: How to fix the 403 forbidden error

404 Not Found[edit]

Fix: Verify that the URL is correct. For more details, see 404 Not Found, possible solutions for pages not found".

405 Method Not Allowed[edit]

Fix: Confirm that the target resource supports the HTTP method you're using. For example, the endpoint may only accept POST requests while you're sending a GET request.

414 Request-URI Too Large[edit]

Fix: Switch from GET to POST so the data is sent in the request body instead of the URL.

415 Unsupported Media Type[edit]

Fix: Explicitly declare the correct Content-Type or Content-Encoding in the request, or access the data directly. For instance, when calling a RESTful API, this error can often be resolved by adding the following header:

Content-Type: application/json

429 Too Many Requests[edit]

Root cause:

  • The client is hitting the website or API more frequently than the service allows.

Fixes:

  • Throttle your requests: Add or increase a delay between requests based on your usage pattern and the service's limits (e.g., pause 1 second between calls).
  • Check the API rate limits: Consult the provider's documentation for limits such as Requests Per Minute (RPM) or Requests Per Day (RPD), and find out whether you can request a higher quota.
  • Use exponential backoff: Detect HTTP 429 responses in your
 application, then retry with progressively longer delays (e.g., 2s → 4s → 8s) until the request succeeds or a maximum retry count is reached.

502 Bad Gateway[edit]

Cause:

  • A failure between upstream network devices/servers — not something the end user can fix directly.

Fixes:

  • Hard-refresh the page to bypass the browser cache
  • Wait a moment and try again

Error 1020: Access Denied[edit]

  • See the linked guide on resolving Error 1020 (Access Denied) to restore access to your website.

HTTP Cats or Dogs[edit]

200.jpg

From HTTP Cats

Related websites:

Other possible root causes[edit]

  • CDN (Content delivery network)

Mock HTTP status error page tools[edit]

The testing sites that can return 500 and various other HTTP status codes on demand

Related pages[edit]

References[edit]


Troubleshooting of ...

Template