32

I had set proxy settings in cmd when I was in a proxy network as follows:

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?

ant_1618
  • 1,861
  • 4
  • 17
  • 26
  • 4
    If you actually used the `set` command as shown, the settings will disappear as soon as you close that particular command window. Or you can say `set http_proxy=` and `set https_proxy=` to delete them. If you actually set the variables with the GUI, it would be simplest to delete them the same way. – Harry Johnston May 22 '15 at 22:52

8 Answers8

61

try,

set http_proxy=
set https_proxy=
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
user5589186
  • 642
  • 7
  • 3
  • 3
    I have tried this and it worked for current session in cmd, But when I open new cmd again my old proxy url is set and again I have to use "set http_proxy=" to clear it. – Arunkumar Arjunan May 21 '19 at 09:26
17

From an elevated command prompt (CMD or PS) type:

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.

G_Style
  • 588
  • 8
  • 16
  • This worked for me when not all requests were going through Fiddler. Not sure if the accepted answer will work in this case. – Arundale Ramanathan Feb 08 '21 at 13:51
  • I'm not sure about my comment, but you may need to restart your system after making any changes on this (I did it after applying this changes and troubleshooting my proxy issue in VS22). – carloswm85 Jul 07 '23 at 15:09
  • As indicated in the answer, this instantly changes your proxy settings for the system. If you are having an application issue, a restart may be necessary for the application to process the system environment changes. – G_Style Jul 10 '23 at 18:49
2
npm config delete proxy http

npm config delete proxy https
Papershine
  • 4,995
  • 2
  • 24
  • 48
Manpreet Kaur
  • 191
  • 1
  • 5
  • 4
    While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations! – Filnor Sep 18 '18 at 07:02
1

Run CMD or Powershell as elevated privilege(Run as administrator)
Then run command netsh winhttp reset proxy.

P.S: 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 automatically.

Tushar
  • 880
  • 9
  • 17
  • An elevated command prompt IS running a shell as administrator. – G_Style Apr 26 '21 at 07:48
  • Can you please explain, what you are trying to say? – Tushar Apr 29 '21 at 12:46
  • Well you said the same thing I answered previously. I thought perhaps you weren't familiar with the term 'elevated prompt', which is what running a command prompt as an administrator is. – G_Style Apr 30 '21 at 03:22
0

Try below steps

  1. Open cmd prompt as administrator
  2. Execute netsh winhttp reset proxy
  3. Execute netsh winhttp show proxy - you should see your current proxy settings as Direct access (no proxy server).
  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.
  5. execute echo %HTTP_PROXY% - it should return nothing.

Let me know if it works, cheers!

Kiran Modini
  • 1,184
  • 8
  • 5
0

To delete variables for future cmd instances:

    setx http_proxy ""
    setx https_proxy ""
0

I've read the urllib.request.proxyhandler.

The easiest way (test and approuved by myself) is to add an no_proxy such as this :

SET no_proxy=abc.com,john.com:8080
alex
  • 1
0
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v proxyEnable /t REG_DWORD /d 1 /f

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d ip_address:port /f

Try this