How Do You Solve a Yum Install/Update Error That Says “Failed to connect to … connection refused”?

Problem:  When trying to use yum commands with a repository on your network, you receive "Failed to connect to x.x.x.x:80; Connection refused" (where x.x.x.x is the IP address of the yum repository server).  What are some possible solutions to this problem?

Potential solutions:
1)  Verify the Linux server with the repository has a valid repository created.  Use "createrepo <directoryToRPMfiles>"

2)  Verify Apache's httpd.conf file has a DocumentRoot value for the directory that was used with the createrepo command above.  This command can help you find it:
     cd /; find . -name httpd.conf | xargs cat * | grep DocumentRoot

3)  Verify that Apache is running: ps -ef | grep apache
These commands may help you start apache depending on your distribution of Linux:
     a) systemctl start httpd.service
     b) service apache2 restart
     c) apachectl start

4) Verify the firewall is not on.  Use ps -ef | grep firewalld to see if it is running.  If you are allowed to disabled the firewall, turn it off with "service firewalld stop".  Only do this if you know you have enough security measures in place for this to not cause a problem.  Turning off a firewall can be a bad idea; be sure other parties involved approve of this change.

5)  Use ping to establish connectivity.  This will not test port 80 or any port for that matter.  You could use "nmap -p 80 x.x.x.x" (where x.x.x.x is the IP address of the server with the yum repository).  If an intermediate firewall was installed that blocks port 80, that may explain the problem.  traceroute is another Linux utility that may be of some value here.

Leave a comment

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