Kamal Saleh Kamal Saleh - 4 months ago 16
PHP Question

file_get_contents( ) not working

I have a script that uses

to get json response from remote server .
is working properly on local files but not working with http or https it gives me the following error
file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in
file_get_contents(https://api.domain.com/resolve.json?url=blablabla): failed to open stream: no suitable wrapper could be found
.. it is a dedicated server and I have WHM .. I've tried

  1. setting
    allow_url_fopen = on
    on WHM PHP configuration Editor but This didn't work.

  2. creating a php.ini file with
    allow_url_fopen = on
    in the directory where the error occurred but this didn't work.

  3. added
    ini_set('allow_url_fopen', 'On');
    to the start of the PHP script but this didn't work .

I know I can use Curl instead but I want to know why this is not working .. the script is working properly on other server and localhost

update :


gives me

allow_url_fopen Off
allow_url_include Off
always_populate_raw_post_data Off

that means my php.ini changes didn't take effect .. what I'm doing wrong ?

mmm mmm

Login to your server via ssh and type

sudo nano /etc/php5/apache2/php.ini //<<<< ubuntu/debian server, might differ for you

in the file, simply press "ctrl + w" and type "allow_url_fopen" and Return, most probably you will come to the explanation first, so repeat the search a couple of times. Now you can change the entry from




press "ctrl + x" and confirm the file save with "y".

Then type

sudo service apache2 restart

This will restart apache so the new php.ini configuration can be loaded. After those steps, you should be able to use file_get_contents externally.


If you can't find your php.ini file, you will find the path to the loaded php.ini file in the top section of your phpinfo()

enter image description here