How to install .rpm packages behind proxy

Last updated on July 20, 2013 by Dan Nanni

RPM (RPM Package Manager) is a command-line utility for installing, removing, querying and updating .RPM packages for RedHat-based systems such as CentOS, RHEL or Fedora. Using rpm command, you can install a package from a locally downloaded .RPM package file or from a URL of a remotely available package.

This article describes how you can install .RPM package from a URL when you are behind a proxy.

In typical scenarios where you are not behind a proxy, you can install from a URL with rpm as follows.

$ sudo rpm -Uvh

If you are behind a proxy, there are two ways to configure the proxy for rpm command.

Method One

The first method is to use command line options for rpm command. To install a .RPM package behind a proxy, run rpm command in the following format.

$ sudo rpm -ivh --httpproxy [proxy server's IP address or host name] --httpport [proxy port number]  [URL of a RPM file]

For example, if your proxy is located at

$ sudo rpm -ivh --httpproxy --httpport 8000

Method Two

The second method to install .RPM packages through a proxy is to use environment variables called http_proxy and https_proxy. If you want, you can set those environment variables system-wide.

As long as the http_proxy and https_proxy environment variables are pointing to your proxy (e.g.,, you don't have to specify the proxy via command-line options for yum command like the first method.

One caveat of this approach is that any environment variable that you define could be reset and lost with sudo. Therefore, you need to make sure that the http_proxy and https_proxy environment variables are preserved in sudo sessions. To do so, append http_proxy and https_proxy to env_keep variable in the sudo configuration file, as follows.

$ sudo visudo
Defaults    env_reset. . . .
Defaults    env_keep += "http_proxy"
Defaults    env_keep += "https_proxy"

With the above configuration, the http_proxy and https_proxy environment variables will be kept while you are running sudo commands. Now, you can install .RPM packages from their URL sources as follows, even when you are behind behind a proxy.

$ sudo rpm -ivh --httpproxy --httpport 8000

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal (Credit Card) or Bitcoin (BTC Wallet: 1M161JGAkz3oaHNvTiPFjNYkeABox8rb4g).

Xmodulo © 2020 ‒ About ‒ Powered by DigitalOcean