संपादित करें

इसके माध्यम से साझा किया गया


Get and analyze HTTP response codes

If an application responds to HTTP or HTTPS requests, you can check the HTTP response codes to determine the behavior of the application.

Prerequisites

  • The Client URL (cURL) tool, or another similar command-line tool.

  • The Kubernetes kubectl tool, or a similar tool to connect to the cluster. To install kubectl by using Azure CLI, run the az aks install-cli command.

Get HTTP response codes by using cURL

The cURL command-line tool can send an HTTP request to an application endpoint and get the response. For a load balancer service (that responds on the path "/" on port 80), a curl request can be initiated by running the following command:

curl -Iv http://<load-balancer-service-ip-address>:80/

For example, you can use cURL together with the kubectl get command, as follows:

$ kubectl get service
NAME                      TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
my-loadbalancer-service   LoadBalancer   10.0.81.95     20.62.x.x       80:32131/TCP   18h
  
$ curl -Iv http://20.62.x.x:80/
*   Trying 20.62.x.x:80...
* Connected to 20.62.x.x (20.62.x.x) port 80 (#0)
> HEAD / HTTP/1.1
> Host: 20.62.x.x
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< ...
...
< Server: Apache/2.4.52 (Unix)
Server: Apache/2.4.52 (Unix)
< ...
...
<
* Connection #0 to host 20.62.x.x left intact

The response from this URI is HTTP 200.

Get HTTP response codes by using a browser

You can also get the HTTP response of an HTTP endpoint from a browser. Follow these steps:

  1. In a browser window, press Ctrl+Shift+I or F12. The developer tools window or pane appears.

  2. Select the Network tab, and then access the endpoint. The details about the HTTP response appear in the developer tools window or pane.

Get HTTP response codes by issuing API requests

To make API requests to the application and get details about the response, you can choose from many other command-line and GUI tools. These tools include the following:

Tool Link
Postman Postman API platform
wget GNU Wget 1.21.1-dirty Manual
PowerShell Invoke-WebRequest cmdlet

After you get an HTTP response code, start troubleshooting to better understand the application's behavior. For more information about the HTTP status codes and the behavior that they indicate, see the following content:

Information source Link
Internet Assigned Numbers Authority (IANA) Hypertext Transfer Protocol (HTTP) status code registry
Mozilla HTTP response status codes
Wikipedia List of HTTP status codes

The following HTTP status codes might indicate the listed issues.

HTTP status code Issue
4xx

An issue affects the client request. For example, the requested page doesn't exist, or the client doesn't have permission to access the page.

OR

A network blocker exists between the client and the server. For example, traffic is being blocked by a network security group or a firewall.

5xx An issue affects the server. For example, the application is down, or a gateway isn't working.

Contact us for help

If you have questions or need help, create a support request, or ask Azure community support. You can also submit product feedback to Azure feedback community.