Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 942
Shika Taga Nai Avatar asked Feb 09 '23 05:02

Shika Taga Nai


1 Answers

add in /etc/hosts
127.0.0.1 project.dev

like image 92
Max P. Avatar answered Feb 11 '23 00:02

Max P.