MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to Configure HTTP/HTTPS Proxy on Linux and Windows (CLI, GUI, Registry, and APT)

Originally published on 2016-07-28; fully revised and updated.

If your network requires a proxy server, CLI tools may fail until proxy variables are configured. This guide helps DevOps engineers and administrators set http_proxy/https_proxy on Windows and Linux, make settings persistent, and fix common issues.

This revision is based on the original post: How to Set or Configure Proxy in Linux and Windows System.

Proxy configuration in Linux and Windows

When proxy settings are needed

  • Your organization routes outbound traffic through a proxy or firewall.
  • Commands such as package installs or API calls fail from terminal sessions.
  • You need different proxy scopes: current shell, system-wide, or tool-specific (for example, apt).

Proxy setup workflow

Use this flow to choose the right level of configuration and troubleshoot quickly.

flowchart TD
    A[Need outbound internet access] --> B{Operating system}
    B -- Windows --> C[Set proxy in shell or system settings]
    B -- Linux --> D[Export proxy variables]
    C --> E[Test command line access]
    D --> E
    E --> F{Still failing}
    F -- Yes --> G[Configure tool specific proxy such as apt]
    G --> H[If using sudo pass proxy variables]
    F -- No --> I[Done]

Windows vs Linux proxy methods at a glance

MethodPlatformScopeBest forNotes
Shell environment variablesWindows / LinuxCurrent terminal sessionQuick testingLost when terminal closes
System Environment Variables (GUI)WindowsUser or system-widePersistent app behaviorUI path varies by Windows version
Registry + WinHTTP importWindowsWinINET and WinHTTP alignmentCentralized Windows proxy setupRequires careful validation
/etc/environmentLinuxSystem-wide environmentPersistent host defaultsCredentials are stored in plaintext
APT proxy configLinux (Debian/Ubuntu)APT onlyapt/apt-get behind proxyUseful when environment variables are ignored

Configure proxy on Windows

Temporary settings in Command Prompt

These values apply to the current Command Prompt session.

set http_proxy=http://your_proxy:your_port
set https_proxy=http://your_proxy:your_port
set no_proxy=localhost,127.0.0.1,.example.internal

set http_proxy=http://username:password@your_proxy:your_port
set https_proxy=http://username:password@your_proxy:your_portCode language: JavaScript (javascript)

Set environment variables via GUI

  • Open Control Panel and select System.
  • Open Advanced system settings, then click Environment Variables.
  • Under System variables, click New.
  • Add http_proxy and https_proxy with your proxy URL.

Registry and WinHTTP commands

The original post includes registry-based setup and WinHTTP import:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d proxyserveraddress:proxyport /f
netsh winhttp import proxy source=ieCode language: JavaScript (javascript)

Enable, disable, or change proxy quickly

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d proxyserveraddress:proxyport /fCode language: JavaScript (javascript)

Legacy credential keys from the original post

The source also listed these keys; validate behavior in your Windows version before relying on them for authentication.

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 passwordCode language: JavaScript (javascript)

Configure proxy on Linux

Temporary settings for the current shell

export http_proxy=http://your_proxy:your_port
export https_proxy=http://your_proxy:your_port
export no_proxy=localhost,127.0.0.1,.example.internal

export http_proxy=http://username:password@your_proxy:your_port
export https_proxy=http://username:password@your_proxy:your_portCode language: JavaScript (javascript)

Persist settings in /etc/environment

The original FAQ points to /etc/environment for Ubuntu system-wide proxy values.

http_proxy="http://your_proxy:your_port"
https_proxy="http://your_proxy:your_port"
no_proxy="localhost,127.0.0.1,.example.internal"Code language: JavaScript (javascript)

Configure apt to use a proxy

If apt does not use your shell variables, add explicit proxy lines:

Acquire::http::Proxy "http://10.1.3.1:8080/";
Acquire::https::Proxy "http://10.1.3.1:8080/";Code language: PHP (php)

When sudo does not pass proxy variables

From the original FAQ: a common failure is that sudo does not pass the proxy environment variable by default.

sudo env http_proxy=http://10.1.3.1:8080 apt-get updateCode language: JavaScript (javascript)

FAQ and quick troubleshooting

  • If your proxy password contains @, try URL-encoding it as %40.
  • If manual export works but apt-get with sudo fails, pass variables explicitly or adjust sudo policy.
  • Remember that some tools read environment variables, while others require tool-specific configuration.
echo $http_proxy
echo $https_proxy
echo $no_proxy
env | grep -i proxyCode language: PHP (php)

Common pitfalls and best practices

  • Set both http_proxy and https_proxy to avoid inconsistent behavior.
  • Avoid storing credentials in plaintext where possible; prefer secure secret handling mechanisms.
  • Use URL encoding for special characters in usernames/passwords.
  • Document a rollback path (for example, disabling proxy values) for incident response.
  • Validate each target tool (curl, apt, build agents) because proxy handling differs by client.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Using http and https proxy in terraform

For Windows environment , set the proxy property like below in dos prompt or permanently in windows environment variable. Then run terraform script, it should work. For…

Read More

How to setup Kubernetes clustors in HTTP Proxy corporate environment

HTTP Proxy corporate environment for kubernetes can be fixed by including all my cluster node IPs in NO_PROXY and using the same NO_PROXY on all the minions…

Read More

How to pass http proxy to ansible using environment variables?

It is quite possible that you may need to get package updates through a proxy, or even get some package updates through a proxy and access other…

Read More

How to set Security Credentials in a AWS Code Build

AWS CodeBuild should get its AWS credentials from an IAM service role attached to the build project, not from access keys typed into environment variables. This guide…

Read More

Designing a production-ready web scraping pipeline that survives blocks, retries, and CI

Most scraping failures in production look like random network noise. The real cause is usually a weak contract between your code and the target site. You deploy…

Read More

HCP Terraform (Terraform Cloud) — Complete Guide to Variables, Scope & Precedence

Updated: October 2026 | Based on current HashiCorp documentation HCP Terraform provides several ways to pass values to Terraform code. These include variable defaults, .tfvars files, environment…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
1 month ago

Proxy settings can affect more than browser access, especially when command-line tools need internet access. It is important to check both system settings and environment variables on Linux and Windows. Teams should also verify proxy addresses, ports, and authentication details before testing connections. For security, avoid storing passwords directly in scripts or shared configuration files. Clear documentation makes proxy issues easier to find and fix across different systems.

1
0
Would love your thoughts, please comment.x
()
x