简体   繁体   English

从 Windows 命令提示符中删除代理设置

[英]Remove proxy settings from the windows command prompt

I had set proxy settings in cmd when I was in a proxy network as follows:当我在代理网络中时,我在 cmd 中设置了代理设置,如下所示:

set http_proxy=http://username:pass@hostname:port

set https_proxy=https://username:pass@hostname:port

Now that I am on a normal network I want to unset the proxy settings in the command prompt.Is there any direct command that would let me unset the http_proxy and https_proxy environment variables directly for the command line rather that navigating through the GUI to delete them?现在我在普通网络上,我想在命令提示符中取消设置代理设置。是否有任何直接命令可以让我直接为命令行取消设置http_proxyhttps_proxy环境变量,而不是通过 GUI 导航来删除它们?

try,尝试,

set http_proxy=
set https_proxy=

From an elevated command prompt (CMD or PS) type:从提升的命令提示符(CMD 或 PS)键入:

netsh winhttp reset proxy

This should produce:这应该产生:

C:\\Windows\\system32>netsh winhttp reset proxy Current WinHTTP proxy settings: Direct access (no proxy server).

This command will reset your proxy settings and as you can see by the output, they will be set to "no proxy server."此命令将重置您的代理设置,正如您在输出中看到的那样,它们将设置为“无代理服务器”。

You can also type netsh winhttp show proxy to see what your current settings are.您还可以键入netsh winhttp show proxy以查看您当前的设置。

npm config delete proxy http

npm config delete proxy https

When you try to set proxy using set http_proxy=http://username:pass@hostname:port then during the exit of the command prompt, the proxy might get reset.当您尝试使用set http_proxy=http://username:pass@hostname:port设置代理时,在退出命令提示符期间,代理可能会重置。
But, Instead you can reset it via Command: netsh winhttp reset proxy .但是,您可以通过命令重置它: netsh winhttp reset proxy

Note: Run command Prompt as administrator注意:以管理员身份运行命令提示符

Try below steps尝试以下步骤

  1. Open cmd prompt as administrator以管理员身份打开cmd提示符
  2. Execute netsh winhttp reset proxy执行netsh winhttp 重置代理
  3. Execute netsh winhttp show proxy - you should see your current proxy settings as Direct access (no proxy server).执行netsh winhttp show proxy - 您应该看到您当前的代理设置为直接访问(无代理服务器)。
  4. Reboot PC - I didn't reboot my pc after running above commands and I still got proxy issues when I did echo %HTTP_PROXY% , rebooting cleared the proxy permanently.重新启动 PC - 运行上述命令后我没有重新启动我的 PC,当我执行echo %HTTP_PROXY%时,我仍然遇到代理问题,重新启动永久清除了代理。
  5. execute echo %HTTP_PROXY% - it should return nothing.执行echo %HTTP_PROXY% - 它应该什么都不返回。

Let me know if it works, cheers!让我知道它是否有效,干杯!

To delete variables for future cmd instances:删除未来 cmd 实例的变量:

    setx http_proxy ""
    setx https_proxy ""

I've read the urllib.request.proxyhandler.我已经阅读了 urllib.request.proxyhandler。

The easiest way (test and approuved by myself) is to add an no_proxy such as this :最简单的方法(由我自己测试和批准)是添加一个 no_proxy ,例如:

SET no_proxy=abc.com,john.com:8080

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM