Shika Taga Nai
Shika Taga Nai

Reputation: 73

How to use php cURL on local vagrant?

I have the following piece of code which works on my remote server

$myCurl = curl_init();
curl_setopt_array($myCurl, array(
    CURLOPT_URL => "http://{$_SERVER['HTTP_HOST']}/social/api/auth/login_or_register",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => http_build_query($credentials)
    ));
$exec = curl_exec($myCurl);

I decided to port the project to local for further development so I have set up a vagrant virtual machine with everything needs, everything seems to work normally except the piece of code above which gives me the following error:

Curl failed with error #7: Failed to connect to project.dev port 8000: Connection refused

Any hints on how I can work around this problem so that I can develop normally on local ?

Upvotes: 4

Views: 2100

Answers (1)

Max P.
Max P.

Reputation: 5679

add in /etc/hosts
127.0.0.1 project.dev

Upvotes: 8

Related Questions