Assume that you want to set 127.0.0.1:10809 as HTTP proxy and 127.0.0.1:10808 as SOCKS proxy.
How to set a proxy for CMD/Powershell/Terminal/Git
CMD / PowerShell Using netsh
Configure the proxy server manually using netsh command
Tunnel all your internet traffic through a HTTP proxy
netsh winhttp set proxy 127.0.0.1:10809 bypass-list="localhost"
Tunnel all your internet traffic through a SOCKS proxy
netsh winhttp set proxy proxy-server="socks=127.0.0.1:10808" bypass-list="localhost"
View the current proxy settings:
netsh winhttp show proxy
Clear all proxy settings:
netsh winhttp reset proxy
CMD / PowerShell Using Env. Variables
Set
set http_proxy=http://127.0.0.1:10809
set https_proxy=http://127.0.0.1:10809
Unset
set http_proxy=
set https_proxy=
To delete variables for future cmd instances, do this:
setx http_proxy ""
setx https_proxy ""
PowerShell Using Env. Variables
$env:HTTPS_PROXY="http://127.0.0.1:10809"
$env:HTTP_PROXY="http://127.0.0.1:10809"
$env:all_proxy="socks5://127.0.0.1:10808"
Bash
export https_proxy=http://127.0.0.1:10809
export http_proxy=http://127.0.0.1:10809
export all_proxy=socks5://127.0.0.1:10808
Git
Set
git config --global http.proxy http://127.0.0.1:10809
git config --global https.proxy http://127.0.0.1:10809
git config --global http.proxy socks5://127.0.0.1:10808
git config --global https.proxy socks5://127.0.0.1:10808
Show
git config --get --global http.proxy
git config --get --global https.proxy
git config --get --global http.proxy socks5
git config --get --global https.proxy socks5
Unset
git config --global --unset http.proxy
git config --global --unset https.proxy
git config --global --unset http.proxy socks5
git config --global --unset https.proxy socks5
You may wonder how to find out what proxy server you are using on a Windows machine.
Proxy settings in Windows can be configured system-wide (for all users of the same computer) or per-user.
In this note i will show how to display system-wide and user-specific proxy settings in Windows from the command-line (CMD) and PowerShell.
Cool Tip: Check if TCP port is opened in PowerShell! Read more →
Show system-wide proxy settings using the netsh winhttp command:
C:\> netsh winhttp show proxy
Get user-specific proxy settings from PowerShell:
PS C:\> Get-ItemProperty -Path "Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Show user-specific proxy settings from CMD:
C:\> reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Was it useful? Share this post with the world!
Once in a while I need to download and install Python packages at work and having switched to Linux (Ubuntu) at home, I find it quite annoying now to have to go to a website, download the package I need, then manually install.
Fortunately, the pip installer works for Windows as well, allowing the installation of Python packages automatically with a simple command (pip install package_name). But at work, we’re behind a proxy server so I have to set the HTTP_PROXY environment variable first before pip can connect to download the packages.
You can set this environment variable permanently so you don’t have to keep re-typing it every time you open a cmd window, but since our proxy requires authentication I prefer not to hardcode it (plus I’ll have to remember to update when my password changes).
Simply type this in the cmd window to set it (note that the setting will get deleted once you close the window):
set HTTP_PROXY=http://user:password@proxy.domain.com:port
In Windows, it’s common to use a proxy server for network connections such as the internet. This is particularly prevalent in corporate or educational environments, where proxy servers are set up for enhanced security and access management. However, proxy settings can frequently change due to network environment changes or security policy updates. Knowing how to check and change proxy settings through the Windows Command Prompt can allow for swift responses in such situations. This article provides a detailed explanation of how to check and change proxy server settings using the Windows Command Prompt.
TOC
Basics of Windows Command Prompt and Proxy
The Windows Command Prompt is a powerful text-based interface embedded in the Windows OS. It allows you to perform various operations such as executing system tasks, managing files, and configuring networks using just commands. A proxy server sits between the client and the internet, forwarding client requests to the internet on behalf of the client. This enhances network security and enables access control. Proxy settings are crucial as they determine how internet access is handled, and managing these settings is possible through the Windows Command Prompt.
How to Check Proxy Server Settings
To check proxy server settings in Windows, use the Command Prompt. Follow the steps below:
- Open Command Prompt. Search for ‘cmd’ in the Start menu, select ‘Command Prompt’, or press Win + R, type ‘cmd’, and press Enter.
- Next, enter the following command to display proxy settings.
This command will display the proxy server information currently set on the system. The output will vary depending on whether a proxy server is set up or not.
How to Change Proxy Server Settings
To change proxy server settings, follow these steps:
- Open Command Prompt.
- To set up a proxy server, use the following command.
netsh winhttp set proxy [proxy server address]:[port number]
For example, if the proxy server address is ‘192.168.0.1’ and the port number is ‘8080’, you would enter:
netsh winhttp set proxy 192.168.0.1:8080
- To verify the settings, execute the ‘netsh winhttp show proxy’ command again.
With these steps, you can now check and change proxy server settings using the Windows Command Prompt. Utilize this for access control in corporate environments or specific network settings.
Here, we’ve detailed the steps for checking and changing proxy server settings through actual command-line operations. In the next section, we provide practical examples and exercises in real network environments.
Practical Example: Settings in Actual Network Environments
In some environments, you may need to route only specific domain or address access through a proxy server, while connecting directly to the internet for all other accesses. In such cases, you can set proxy exceptions using the Command Prompt.
- To set exceptions, use the following command.
netsh winhttp set proxy proxy-server="http=192.168.0.1:8080" bypass-list="*.example.com"
In this example, ‘192.168.0.1:8080’ is set as the proxy server, and access to the “*.example.com” domain is configured to connect directly, bypassing the proxy.
- To set multiple exceptions, separate domains with semicolons.
netsh winhttp set proxy proxy-server="http=192.168.0.1:8080" bypass-list="*.example.com;*.example.net"
Using the netsh command, you can perform detailed settings for the proxy server. Next, we’ll provide exercises to ensure your understanding of the content learned.
Exercises and Answers
Problem: Write the appropriate commands to perform the following settings in the Command Prompt.
- Set the proxy server ‘proxy.example.com’ with port number ‘8080’.
- Directly connect to the “company.com” domain without going through the proxy.
Answer:
- Command to set up the proxy server:
netsh winhttp set proxy proxy-server="http=proxy.example.com:8080"
- Setting to bypass specific domains:
netsh winhttp set proxy proxy-server="http=proxy.example.com:8080" bypass-list="*.company.com"
This exercise is designed to verify your understanding of basic proxy settings and exceptions, and apply them in real environments.
The practical examples and exercises provided here can help deepen your understanding of proxy server settings in actual network environments and enhance your problem-solving skills. In the next section, we will discuss common issues that may arise during proxy settings and their solutions.
Common Issues and Solutions
When setting up a proxy server, there are some common issues that may arise. Here, we introduce these issues and their solutions.
- Issue: Unable to connect to the internet through the proxy server.
Solution: Check if the proxy server address and port number are correct. Also, verify that the network firewall or security software is not blocking the connection to the proxy server. - Issue: Unable to access certain sites or domains.
Solution: If you have used thebypass-listoption to allow direct access to specific domains, check if those settings are correctly implemented. Also, verify there are no spelling mistakes in the domain names or format errors. - Issue: Error messages appear after executing commands in the Command Prompt.
Solution: Ensure that the syntax of the command is correct. Also, check if you are running the Command Prompt with administrative privileges. For operations requiring administrative rights, right-click the Command Prompt and select ‘Run as administrator’.
By following these troubleshooting steps, you should be able to resolve common issues related to proxy server settings.
Conclusion
This article has explained how to check and change proxy server settings using the Windows Command Prompt. We covered basic setting methods, practical examples, and exercises to deepen your understanding of proxy settings. Additionally, we discussed common issues and solutions during the setup process.
Proper proxy server settings are crucial for strengthening network security and streamlining access management. We hope this article serves as a valuable resource in your daily network management tasks.
- Set proxy through windows command line including login parameters
- Set HTTP(s) Proxy in Windows Command Line / Mac Terminal
- Enable and Configure proxy using CMD
- Configuring proxy from CMD (Windows)
- Configure device proxy and Internet connectivity settings
- Windows: Show Proxy Settings – CMD & PowerShell
- Using the WinHTTP Proxy Configuration Utility
- Remove proxy settings from the windows command prompt
Set proxy through windows command line including login parameters
Once the variable HTTP_PROXY is set, all our subsequent commands executed at
windows command prompt will be able to access internet through the proxy along
with the authentication provided. Additionally if you want to use ftp and
https as well to use the same proxy then you may like to the following
environment variables as well.
netsh winhttp set proxy SERVER:PORT
netsh winhttp set proxy user:[email protected]:PORT
set HTTP_PROXY=http://proxy_userid:[email protected]_ip:proxy_port
set FTP_PROXY=%HTTP_PROXY%
set HTTPS_PROXY=%HTTP_PROXY%
netsh winhttp set proxy proxy-server="socks=localhost:9090" bypass-list="localhost"
netsh winhttp show proxy
netsh winhttp reset proxy
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d name:port
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyUser /t REG_SZ /d username
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyPass /t REG_SZ /d password
netsh winhttp import proxy source=ie
Set HTTP(s) Proxy in Windows Command Line / Mac Terminal
Windows Command Line. In Windows Command Line environment (NOT powershell),
you can use below commands to set http and https proxy. set
http_proxy=protocol://ip:port set https_proxy=protocol://ip:port. For example,
if you have a local socks 5 proxy (such as ShadowSocks), commands will be as
below.
set http_proxy=protocol://ip:port
set https_proxy=protocol://ip:port
set http_proxy=socks5://127.0.0.1:1086
set https_proxy=socks5://127.0.0.1:1086
echo %http_proxy%
echo %https_proxy%
set http_proxy=
set https_proxy=
export http_proxy=socks5://127.0.0.1:1086 # Set HTTP Proxy
export https_proxy=socks5://127.0.0.1:1086 # Set HTTPS Proxy
export all_proxy=socks5://127.0.0.1:1086 # Set HTTP & HTTPS Proxy
unset http_proxy
unset https_proxy
Enable and Configure proxy using CMD
On Windows, one can modify the network settings via commandline by using the
netsh command. For example, changing the proxy works as follows: netsh winhttp
set proxy myproxy or in your scenario: netsh winhttp set proxy
10.10.10.10:1111 Have a look at the detailed documentation here, and at this
superuser thread
netsh winhttp set proxy myproxy
netsh winhttp set proxy 10.10.10.10:1111
Configuring proxy from CMD (Windows)
If you need to access the proxy low level configuration, you will need to use
a CMD Window as Local Administrator and use the netsh interface and use the
following: 1 2 3. netsh winhttp show proxy — to show the current
confiuguration netsh winhttp reset proxy — to delete the current settings
netsh winhttp set proxy <proxyName>:<port> — to set a
1
2
3
netsh winhttp show proxy - to show the current confiuguration
netsh winhttp reset proxy - to delete the current settings
netsh winhttp set proxy <proxyName>:<port> - to set a new configuration
1
2
set HTTP_PROXY=http://[username:[email protected]]proxyserver:port
set HTTPS_PROXY=https://[username:[email protected]]proxyserver:port
Configure device proxy and Internet connectivity settings
Right-click Command prompt and select Run as administrator. Enter the
following command and press Enter: netsh winhttp set proxy <proxy>:<port> For
example: netsh winhttp set proxy 10.0.0.6:8080. To reset the winhttp proxy,
enter the following command and press Enter: netsh winhttp reset proxy
<server name or ip>:<port>
For example: http://10.0.0.6:8080
netsh winhttp set proxy <proxy>:<port>
netsh winhttp reset proxy
HardDrivePath\MDEClientAnalyzer.cmd
C:\Work\tools\MDEClientAnalyzer\MDEClientAnalyzer.cmd
Testing URL : https://xxx.microsoft.com/xxx
1 - Default proxy: Succeeded (200)
2 - Proxy auto discovery (WPAD): Succeeded (200)
3 - Proxy disabled: Succeeded (200)
4 - Named proxy: Doesn't exist
5 - Command line proxy: Doesn't exist
Windows: Show Proxy Settings – CMD & PowerShell
Proxy settings in Windows can be configured system-wide (for all users of the
same computer) or per-user. In this note i will show how to display system-
wide and user-specific proxy settings in Windows from the command-line (CMD)
and PowerShell. Cool Tip: Check if TCP port is opened in PowerShell! Read more
→. Show Proxy Settings in Windows
C:\> netsh winhttp show proxy
PS C:\> Get-ItemProperty -Path "Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
C:\> reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Using the WinHTTP Proxy Configuration Utility
The WinHTTP proxy configuration utility, proxycfg.exe, configures WinHTTP to
access HTTP and HTTPS servers through a proxy server. Because the
ServerXMLHTTP object depends on WinHTTP proxy settings, an administrator can
use the proxycfg.exe utility as part of the deployment and installation
process of an application that uses WinHTTP.
proxycfg -d -p itgproxy "<local>"
proxycfg -p itgproxy
proxycfg -p "http=http_proxy https=https_proxy" "<local>;*.microsoft.com"
Remove proxy settings from the windows command prompt
set http_proxy= set https_proxy= 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
set http_proxy=
set https_proxy=
npm config delete proxy http
npm config delete proxy https
