How to install .rpm packages behind proxy

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 file, as well as from a URL of a remotely available package.

In this article, I will describe how to 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 -ivh

However if you are behind a proxy, the above command will produce the following error.

curl: (7) couldn't connect to host
error: skipping - transfer failed

There are two ways to configure your proxy with the rpm command.

Method One

The first method is to use rpm's command-line options. That is, run the rpm command in the following format to specify your proxy.

$ 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 an environment variable named http_proxy. If you want, you can set the environment variable system-wide.

As long as the http_proxy environment variable is pointing to your proxy (e.g.,, you don't have to specify the proxy via command-line options 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 environment variable is preserved in sudo sessions. To do so, append "http_proxy" to "env_keep" variable in the sudo configuration file, as follows.

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

With the above configuration, the http_proxy environment variable 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 a proxy.

$ sudo rpm -ivh

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

Leave a comment

Your email address will not be published. Required fields are marked *