My CentOS Linux based laptop can only be accessed through our corporate proxy servers. How do I access and use yum command with a Web proxy server on a CentOS / RHEL / Fedora / Red Hat / Scientific Linux?

Yum repositories can be accessed through standard proxy servers such as Squid proxy server. You need to provide use the following details of the proxy server in /etc/yum.conf file: [donotprint]
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements None
Est. reading time 2m
  1. proxy=http://URL:PORT/ – Proxy serer URL to the proxy server that yum should use. You must seta complete URL, including the TCP port number. If your corporate proxy server requires a username and password, specify these by adding following two settings in yum.conf file itself.
  2. proxy_username=YOUR-PROXY-USERNAME-HERE (optional)- Your proxy server username to use for the proxy URL.
  3. proxy_password=YOUR-SUPER-secrete-PASSWORD-HERE (optional) – Your proxy server password for this proxy URL.

Configuration: Using yum with a proxy server on a CentOS/RHEL/Fedora Linux

Login as root user and type:
# vi /etc/yum.conf
Add the following settings in [main] section:


Here is a complete config /etc/yum.conf file:

exclude=lighttpd* nginx* spawn-fcgi* webalizer*

Save and close the file. Please note that defining a proxy server, username, and password in /etc/yum.conf means that all users connect to the proxy server with those details when using yum command:
# yum update
# yum install httpd php php-gd php-mysql

How do I enable proxy access for a specific user such as root user only?

Linux and UNIX-like system has environment variable called http_proxy. It allows you to connect text based session and applications via the proxy server. Type the following command at shell prompt:
# export http_proxy=""
# export http_proxy=""

Feel free to add the above line in the to your shell profile file such as ~/.bash_profile. See how to set or export: http_proxy with special characters in password on a Unix or Linux based system for more information.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • Jalal Hajigholamali Jun 4, 2014 @ 5:26


    Very nice article….

  • Alen Krmelj Jun 4, 2014 @ 13:36

    Yum uses mirror list, so such proxy is semi-effective…

    • Pedro Rodriguez Jun 5, 2014 @ 14:35

      you have not understood why we use a proxy.

      yum uses mirror right, but here we are talking about a company that blocks access to outside world to almost all our server, allowing maybe only a couple of servers to reach these yum mirror.
      that’s why we create a proxy in one of our “external” servers

  • foobrew Jun 4, 2014 @ 19:26

    Has anyone tried doing an upgrade (“fedup”) with a proxy? I’d be surprised if it works.

  • Shailen TJ Aug 3, 2014 @ 14:18

    How do I configure yum to use the system proxy that was configured in the settings?

    I don’t want to have multiple proxy settings set up everywhere, for every app because I wrote a script to control the system proxy. When I am at home, I switch off the proxy using the script.

  • artyom Feb 11, 2015 @ 5:09

    Thank you very much!
    It is one of the first works that I could try in CentOS.

  • Mohamoud May 7, 2015 @ 13:18

    I’m using CNTLM proxy and adding the local proxy to yum.conf
    In the cntlm proxy configuration file ./etc/cntlm.conf you can create a password hash.
    So you’re password remains secure.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum