allow_url_fopen PHP Origin: Application & API OSI layer 7 · Application Last updated 2 Dec 2026

Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0

The server forbids PHP from opening URLs with file functions.

Exact message you may see http:// wrapper is disabled in the server configuration by allow_url_fopen=0URL file-access is disabled in the server configuration
Seen on: PHP

Meaning

Hosts disable allow_url_fopen for security. file_get_contents('https://…') and fopen on URLs then fail.

Common causes

  • allow_url_fopen=Off in php.ini
  • Shared host policy
  • allow_url_include confusion

⚡ Quick fix

  1. Use cURL instead of file_get_contents for URLs
  2. Enable allow_url_fopen where allowed
  3. Use Guzzle or Symfony HttpClient

Detailed fix by platform

PHP

  1. $ch = curl_init($url); curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10]); $body = curl_exec($ch);

How to diagnose

  1. ini — php -i | grep allow_url?
  2. Host — Shared hosting policy?
  3. Alternative — cURL available?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Allowed memory size exhausted — PHP Fatal error: Allowed memory size of X bytes exhausted (PHP)Allowed memory size e…ArgumentCountError — Fatal error: Uncaught ArgumentCountError: Too few arguments to function foo(), 1 passed and exactly 2 expected (PHP)ArgumentCountErrorArray to string conversion — Warning: Array to string conversion (PHP)Array to string conve…Call to member function on null — Fatal error: Uncaught Error: Call to a member function x() on null (PHP)Call to member functi…cURL error 6 — cURL error 6: Could not resolve host: api.example.com (PHP)cURL error 6failed to open stream — Warning: include(x.php): Failed to open stream: No such file or directory (PHP)failed to open streamSSL operation failed — Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: certificate verify failed (PHP)SSL operation failedallow_url…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.