00:00:00
21 Jul

How to fix pycurl error 7: Yum couldn’t connect to host

Oliver Krautscheid Oct 11, 2014
0 2332

Yum and Apt are great, but not flawless. I frequently encounter hiccups like “couldn’t connect to host”. Let’s troubleshoot this issue


Step 1: Check the log

First, we will look at what yum is actually doing. So perform a yum command like

yum install pip

If you encounter the issue “Another app is currently holding the yum lock; waiting for it to exit” then you need to kill the yum process. The id is listed under “State” on your screen, simply check the number “pid:”

Another App Is Currently Holding The Yum Lock.png

After you run yum again, yum will fetch the CentOS baseurl defined in your CentOS-Base.repo file in /etc/yum.repos.d to connect to the main repository. If this url is different to centos.org, we can easily fix the pycurl error and make it connect to the host again.

As you can imagine, there are quite a few packages that will mess with this file or even your host may mess with this file, so all we have to do is to go into the folder and fix the baseurl.

Step 2: Fixing CentOS-Base.repo Baseurl

Go into yum.repos.d

cd /etc/yum.repos.d

This path works on CentOS 6/7, but may be different on other Linux distributions.

pico CentOS-Base.repo

Let’s take a quick look at the file.

Ah! Here we go, the baseurl was set incorrectly, preventing your server to properly connect.

Instead of messing with this file, we are going to create a quick backup:

Exit pico

CTRL + X to exit

Move the file

mv CentOS-Base.repo CentOS-Base.repo.bak

Let’s fetch a fresh Base repo from Centos.org:

Go to github for the latest CentOS6 Base repo!

https://github.com/dayne/yum/blob/master/centos6/CentOS-Base.repo

Don’t use wget to download that, you need to open this URL and copy/paste the content or use git to clone it.

pico CentOS-Base.repo

Now paste the content.

VoilĂ , yum is fetching again – from the correct baseurl:

Fixing Yum Pycurl Error 7.Png

Step 3: Check Resolver.conf

Not working for you?

pico /etc/resolv.conf

And comment out the existing nameservers (add two leading ##)

Then insert Google’s nameserver:

nameserver 4.4.4.4
nameserver 8.8.8.8

VoilĂ , yum should fetch again and you should no longer get the error “Yum couldn’t connect to host”.

Still not working? Post a comment below or in our support forums.

Cheers

About Us

Webmaster .Net is your all-in-one resource for blogging tips, system administration guides, industry news and a growing community of webmasters.

Can't find something or want to tip us?Contact@webmaster.net

Bulls and Bears

Leave a Comment

Your email address will not be published.

Webmaster Tutorials, Wordpress
0 shares673 views

WordPress SQL Query: Select And Delete Posts Between Two Dates

Oliver Krautscheid - Apr 08, 2017

If you are wondering how to delete posts for a certain date, you will need to know how Wordpress stores…

Advertising and Ad Networks, Copywriting
0 shares810 views

15 Tips For Increasing Facebook Ads CTR – Full Guide [2017 Update]

Cam Connor - Mar 30, 2017

In this article, we'll talk a lot about how you can write quality text ads on Facebook Ads to get…

Webmaster Tutorials
0 shares1530 views

10 Steps To Configure Nginx For WordPress, Drop Varnish And Cut Your CPU Load By 50%

Oliver Krautscheid - Oct 10, 2016

Are you using Varnish on your Wordpress blog? Possibly the Varnish script by Unixy? Great! Get rid off it. Here's…

Follow Us And get latest news

© 2016 Webmaster.Net - Property of Peakstone Media Ltd. - All rights reserved. | Privacy Policy | DMCA | Contact Us | Advertise