title: Yii curl Couldn't resolve host error CentOs 6
body: <p>I've gotten trouble around the error <code>"Couldn't resolve host '...'"</code>.
  I have also researched through many topics and couldn't find the workaround.</p>
  
  <p>First time, same the code, I could do <code>curl</code> without no problem. But today it suddenly stopped working. Here were my attempts</p>
  
  <ol>
  <li>Same the code in my localhost, <code>curl</code> worked fine.</li>
  <li><p>In my server <code>CentOs 6</code> (using <code>Cpanel</code> Whm), my structure of directories looks like following</p>
  
  <ul>
  <li>public_html</li>
  <li>-YiiWebsiteFolder</li>
  <li>-curl_test.php</li>
  </ul></li>
  </ol>
  
  <p>I could run <code>curl</code> to same URL in <code>curl_test.php</code> without the problem, it worked fine. It also worked even I put the <code>curl_test.php</code> inside the YiiWebsiteFolder, so problem wouldn't not be the permission.</p>
  
  <p>But if I run same code to call <code>curl</code> through <code>Yii</code> (YiiWebsiteFolder), ran it in Yii controller and action, it would raise the error <code>'Couldn't resolve host ...'.</code>
  (my URL rewrite is very normal, my site URL looks like "<code>mydomain.com/index.php/test/myaction</code>" )</p>
  
  <p>So I guessed the cause could be <code>Yii</code>, was not <a href="https://stackoverflow.com/questions/4541479/curl-gives-couldnt-resolve-host">DNS problem</a> like some help topics said.</p>
  
  <p><a href="http://forums.cpanel.net/f34/file_get_contents-couldnt-resolve-host-name-120065.html" rel="nofollow noreferrer">http://forums.cpanel.net/f34/file_get_contents-couldnt-resolve-host-name-120065.html</a></p>
  
  <p><a href="http://forums.freebsd.org/showthread.php?t=29933" rel="nofollow noreferrer">Couldn't resolve host and DNS Resolution failed</a></p>
  
  <p>Both Yii config <code>main.php</code> files of my local machine and my server are same.</p>
  
  <p>Edited: I have found this guy who had same problem like me</p>
  
  <p><a href="https://bbs.archlinux.org/viewtopic.php?id=78849" rel="nofollow noreferrer">cURL doesn't work when it's used in a PHP application and running > through a web browser</a></p>
  
  <blockquote>
    <p>cURL doesn't work when it's used in a PHP application and running
    through a web browser. However, that same PHP page with cURL, when run
    via the terminal, does what it's supposed to do and fetches the
    information that I want</p>
  </blockquote>
  
  <p>But he has found it out the problem is the DAEMON array, but I don't use Apache DAEMON (even I don't sure what it is).</p>
  
  <p>I have tried all of possible solutions such as restarting my network and my apache to change the order when they started, modify <code>etc/resolv.conf</code> / (add or remove 12.0.0.1 and try some public DNS)</p>
  
  <blockquote>
    <p>service network stop</p>
    
    <p>service network start</p>
    
    <p>service network restart</p>
    
    <p>/sbin/service httpd stop</p>
    
    <p>/sbin/service httpd start</p>
  </blockquote>
  
  <p>I've spent many hours to troubleshoot the problem but no succeed at all.
  Any help is really appreciated.</p>