We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can I make curl to work in my local environment?

Hi, I am doing a simple GET request using curl but I can't make it work. I have curl installed and I was able to do some POST/GET requests to other sites so I know it's working.

class TestsController extends ControllerBase{
    public function curlAction{
        $this->response->setJsonContent(['content' => 'success']);

    public function sendAction(){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://localhost/tests/curl");
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        $output = curl_exec($ch);
        var_dump($output); //result is always false


The curl action works when I am using cli CURL and when using POSTMAN, but no luck when trying the send action. Am I missing something?


When I try to output curl error it says couldn't connect to host.


I got it working. Seems like my installation of curl used a different port. I configured it to the default and it worked.