用 curl 查看网站的 HTTP 状态码

利用 Windows 自带的 curl,只输出网址的 HTTP 状态码(200、404、500……),快速判断网站是否正常。

Windowscurl 请求网络故障排查低风险
运行:curl -s -o NUL -w "%{http_code}" https://example.com,正常网站会输出 200。

01命令

命令
$ curl -s -o NUL -w "%{http_code}" https://example.com

02作用说明

curl 会抓取网页,-o NUL 把内容丢弃,-w "%{http_code}" 只打印数字状态码:200 表示正常、301 是跳转、404 找不到页面、5xx 是服务器错误。想看完整的响应头,可以用 curl -I https://example.com。这是 Windows 自带的、最快检查网站或接口是否存活的方法。

03风险

风险低风险
使用条件Windows 10 (1803+) and 11 include curl.exe by default
!注意: 有些网站会屏蔽命令行请求;如果返回 403,可以加上浏览器标识:-A "Mozilla/5.0"

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • curl.exe - Transfer data from or to a server
    SS64.com · technical · 2026-09-17
    依据: Windows curl reference documenting --head / -I (headers only) and write-out options; headers-only requests show the HTTP status line such as HTTP/1.1 200 OK.
  • curl man page
    curl.se · vendor-doc · 2026-09-17
    依据: Documents -w/--write-out with variables such as %{http_code} (the HTTP response code) and -s/--silent for quiet mode; -o writes the body to a file (NUL discards it).

最后验证: 2026-09-19 · 分类: 网络

06相关方案