Remove proxy settings from the windows command prompt
Asked Answered
R

8

37

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?

Racism answered 22/5, 2015 at 21:28 Comment(1)
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.Libna
A
61

try,

set http_proxy=
set https_proxy=
Another answered 21/11, 2015 at 13:18 Comment(1)
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.Glycerol
Q
22

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.

Quest answered 23/7, 2019 at 20:39 Comment(3)
This worked for me when not all requests were going through Fiddler. Not sure if the accepted answer will work in this case.Prognosis
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).Bloemfontein
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.Quest
C
2
npm config delete proxy http

npm config delete proxy https
Cerumen answered 18/9, 2018 at 6:13 Comment(1)
While this code snippet may solve the question, including an explanation 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!Brockman
P
2

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.

Potence answered 5/1, 2019 at 11:27 Comment(3)
An elevated command prompt IS running a shell as administrator.Quest
Can you please explain, what you are trying to say?Potence
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.Quest
D
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!

Dyslogistic answered 25/9, 2020 at 0:47 Comment(0)
H
0

To delete variables for future cmd instances:

    setx http_proxy ""
    setx https_proxy ""
Holna answered 15/7, 2021 at 20:24 Comment(0)
T
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
Torque answered 25/8, 2021 at 13:1 Comment(1)
this doesn't remove the http_proxy but instead excludes destinations from using the proxyClyde
D
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

Deodand answered 24/4, 2023 at 1:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.