Skip to main content
Proxy Basics

How to Check Proxy Settings in Linux Command Line [2026 Guide]

7 min read

How to Check Proxy Settings in Linux Command Line: The 2025 Expert Guide

As a senior proxy specialist, I often see network engineers and system administrators struggle with connectivity issues that stem from 'ghost' proxy configurations. Linux is transparent, but its flexibility with shell profiles and desktop environments can leave proxy settings scattered across multiple files.

In this comprehensive guide, we will dig deep into how to check proxy settings in the Linux command line. We will move beyond basic environment variables to inspect system-wide configurations, application-specific settings, and active connections.

---

1. Understanding Linux Proxy Variables

Before checking settings, it is vital to understand what we are looking for. Linux does not have a single centralized "proxy settings" file. Instead, it relies on Environment Variables that applications read at runtime.

The standard variables include:

  • http_proxy: Routes HTTP traffic.
  • https_proxy: Routes HTTPS traffic (often the same as HTTP).
  • ftp_proxy: Routes FTP traffic.
  • no_proxy: A comma-separated list of domains that should bypass the proxy (e.g., localhost, 127.0.0.1, .internal.local).
  • all_proxy: A catch-all often used for SOCKS proxies.
  • *Note: These variable names are case-insensitive in many tools but are conventionally lowercase. However, some specific applications (like older Java versions or specific apt-get implementations) might look for uppercase versions (HTTP_PROXY).*

    2. The Primary Method: Environment Variables

    The most common way proxies are enforced in CLI is via environment variables defined in shell configuration files like ~/.bashrc, ~/.bash_profile, ~/.zshrc, or system-wide in /etc/environment.

    Command 1: The Quick Filter

    Open your terminal and run:

    env | grep -i proxy
    

    Breakdown:

  • env: Prints all current environment variables.
  • grep -i proxy: Filters the output to find lines containing "proxy" (case-insensitive).
  • What the output looks like:

    http_proxy=http://proxy.example.com:3128
    

    https_proxy=http://proxy.example.com:3128 no_proxy=localhost,127.0.0.1,.internal.domain

    Command 2: The Specific Check

    If you want to check a specific variable to see if it is empty (unset):

    echo $http_proxy
    

    If this returns an empty line, no proxy is currently set for HTTP traffic in that session.

    Command 3: Checking System-Wide Files

    Sometimes env returns nothing because a user didn't log in with a profile that sets the variables, but the system has them configured globally. Check the global environment file:

    cat /etc/environment | grep -i proxy
    

    You should also check the default profile (often used for system services):

    cat /etc/profile | grep -i proxy
    

    3. Verifying Proxy Connectivity with cURL

    Knowing the *variable* is set is half the battle. Knowing if it actually *works* is the other half. curl is an excellent tool for this because it provides verbose output.

    Testing Directly

    If you have a proxy set in your environment, simply running curl should use it. However, to be explicit and see what is happening:

    curl -v https://www.google.com
    

  • Look for: Lines like * Uses proxy env variable http_proxy='...' or * Trying 10.0.0.1:8080... in the verbose output.

Testing Bypassing the Proxy

To troubleshoot, you may want to temporarily disable the proxy for a single command to see if the proxy is the cause of a failure:

curl --noproxy "*" -v https://www.google.com

This tells curl to ignore the no_proxy variable and essentially try a direct connection (if network policy allows).

4. Checking Specific Package Managers (APT & YUM)

Package managers often have their own proxy configurations that override shell variables. This is a common pain point for sysadmins trying to update Linux servers behind a corporate firewall.

Debian/Ubuntu (APT)

APT typically does not use standard environment variables. Check its specific configuration directory:

cat /etc/apt/apt.conf.d/proxy.conf

*Note: In older systems, this might be in /etc/apt/apt.conf.*

Output example:

Acquire::http::Proxy "http://proxy.example.com:3128";

Acquire::https::Proxy "http://proxy.example.com:3128";

RedHat/CentOS/Fedora (YUM/DNF)

YUM usually respects environment variables, but it can be hardcoded in the main configuration:

cat /etc/yum.conf | grep -i proxy

5. Checking Systemd Services

If a service (like Docker or a web scraper) is failing due to proxy issues, and it runs as a systemd service, checking env in your user shell won't help, because the service runs in a different environment.

To check the proxy environment of a running service (e.g., docker):

systemctl show-environment | grep -i proxy

To view the specific configuration of a service (looking for a Service block containing Environment= directives):

systemctl show docker | grep Environment

To fix this, you usually create an override file:

sudo systemctl edit docker

And add:

[Service]

Environment="HTTP_PROXY=http://proxy.example.com:8080" Environment="HTTPS_PROXY=http://proxy.example.com:8080"

6. Python Environment Proxy Check

Since many users asking this question are likely web scraping with Python, it is crucial to check how Python interprets proxy settings. Python's requests library automatically checks standard OS environment variables (http_proxy, etc.).

You can verify this within a Python script or CLI:

import os

proxy_vars = ['http_proxy', 'https_proxy', 'no_proxy']

for var in proxy_vars: print(f"{var}: {os.environ.get(var, 'Not Set')}")

Real-world Snippet: If you need to test a proxy in Python manually, use this snippet:

import requests

proxies = { 'http': 'http://10.10.1.10:3128', 'https': 'http://10.10.1.10:1080', }

try: response = requests.get('http://httpbin.org/ip', proxies=proxies, timeout=5) print("Proxy working. IP:", response.json()['origin']) except requests.exceptions.ProxyError: print("Proxy Configuration Failed") except Exception as e: print(f"Connection Error: {e}")

7. Comparison: Where Linux Proxies Hide

To save you time, use this table to know where to look based on your symptoms.

| Symptom | Check Command | Location | | :--- | :--- | :--- | | Bash/Curl works, Apps fail | env | grep -i proxy | User Shell Variables (~/.bashrc) | | System Updates fail | cat /etc/apt/apt.conf.d/proxy.conf | Package Manager Config | | Service fails on boot | systemctl show | Systemd Environment | | Git push fails | git config --global --get http.proxy | Git Config (~/.gitconfig) | | Everything is slow | echo $http_proxy | Legacy System Script (/etc/profile.d/) |

8. Expert Troubleshooting Tips

1. Case Sensitivity Issues: While Linux is case-sensitive, not all proxy clients are. curl generally checks both http_proxy and HTTP_PROXY. However, strictly adhering to lowercase is the modern standard.

2. The 'no_proxy' Trap: A common error is setting the proxy correctly but leaving localhost out of the no_proxy list. This causes local services (like Elasticsearch, Docker registries, or local APIs) to fail because traffic is being routed to the external proxy server which cannot handle the local request.

3. Temporary Unset: To quickly verify if a proxy is causing network issues, unset the variables for the current session:

unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY

Conclusion

Checking proxy settings in Linux is rarely about looking in just one place. It is a process of elimination involving environment variables, package manager configs, and service files. Start with env | grep -i proxy, proceed to /etc/environment, and verify connectivity with curl -v. Understanding these layers allows you to diagnose complex networking issues effectively.

Share: