Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

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

Linux pmap Command Guide: Inspect Process Memory Maps with Practical Examples

Learn how to use the Linux pmap command to inspect per-process memory mappings, compare output modes, and troubleshoot high memory usage quickly. This updated guide includes workflow steps, command examples, and interpretation tips.

Read More

iostat Command Guide for Linux: 20 Practical Examples for CPU and Disk I/O Troubleshooting

Learn how to use iostat to monitor CPU and storage performance on Linux systems. This revised guide covers installation, 20 practical commands, metric interpretation, and a troubleshooting workflow.

Read More

xargs in Linux: Practical Commands, Safe Patterns, and Pipeline Workflows

This guide explains how to use xargs effectively in Linux/Unix shells, from basic stdin handling to safe file operations and parallel execution. You’ll learn practical command patterns, portability caveats, and safer alternatives.

Read More

Linux mount and umount Commands: Practical Examples, /etc/fstab, and Safe Unmounting

Learn how to mount and unmount filesystems reliably on Linux, from one-off commands to persistent /etc/fstab entries. This guide covers common filesystem types, command comparisons, and safe troubleshooting steps.

Read More

How to Use gsh to Run Linux Commands Across Multiple Servers

gsh (Group Shell) lets you execute one command across many Linux hosts from a single terminal. This guide explains host grouping with /etc/ghosts, core options, and practical command patterns.

Read More

Linux System Administrator Responsibilities: Daily Operations, Privileges, and Best Practices

Linux system administrators are responsible for server reliability, security, access control, patching, backups, and troubleshooting. This updated guide maps those responsibilities to practical workflows and command examples.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x