# Curl command from terminal works however, php CURL doesnt pull the records

**URL:** <https://discuss.elastic.co/t/curl-command-from-terminal-works-however-php-curl-doesnt-pull-the-records/157268>\
**Category:** Elasticsearch\
**Created:** [November 19, 2018, 5:24am UTC](https://discuss.elastic.co/t/curl-command-from-terminal-works-however-php-curl-doesnt-pull-the-records/157268 "2018-11-19T05:24:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bishwadeep\_Kc](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@Bishwadeep\_Kc](https://discuss.elastic.co/u/Bishwadeep_Kc)\
**Post date:** [November 19, 2018, 5:24am UTC](https://discuss.elastic.co/t/curl-command-from-terminal-works-however-php-curl-doesnt-pull-the-records/157268/1 "2018-11-19T05:24:12Z")

</div>

I have the following php curl commands running on the same server where the ES is installed and running on port 9200.

function($data\_string){  
$ch = curl\_init('[http://localhost:9200/cfaq/\_search](http://localhost:9200/cfaq/_search)');  
curl\_setopt($ch, CURLOPT\_CUSTOMREQUEST, "POST");  
curl\_setopt($ch, CURLOPT\_POSTFIELDS, $data\_string);  
curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);  
curl\_setopt($ch, CURLOPT\_HTTPHEADER, array(  
'Content-Type: application/json',  
'Content-Length: ' . strlen($data\_string))  
);  
$result = curl\_exec($ch);  
}

This curl function is returning the following whatever Search Query i use.

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}

However, when I try same search query on same server using terminal curl command (eg: curl -X POST '[http://localhost:9200/cfaq/\_search?q=Job](http://localhost:9200/cfaq/_search?q=Job)'), I get the desired  
results. Here is my configuration on elasticsearch.yml file:

* * *

bootstrap.memory\_lock: true  
network.host: localhost  
http.port: 9200

* * *

My Elastic search version is 6.5.0  
Please let me know if you have any questions.  
Can you please let me know what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 17, 2018, 5:24am UTC](https://discuss.elastic.co/t/curl-command-from-terminal-works-however-php-curl-doesnt-pull-the-records/157268/2 "2018-12-17T05:24:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
