URL file-access is disabled in the server configuration

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, November 11, 2008

Follow me on Twitter as @mattiasgeniar

When opening external URL’s through PHP, you might stumble upon the dreaded “URL file-access is disabled in the server configuration”-error message.

It just means that remote access was disabled in the server configuration, so you can’t load external files (say: images, text files, xml files, …). If the server allows you to override the server configuration in PHP scripts, you can do the following on top of the page you’re experiencing this problem.

<?php
ini_set('allow_url_fopen', 'on');
// .....
?>

If that’s not allowed, you can change this setting in the php.ini file, maintained by your server administrator.

/*;;;;;;;;;;;;;;;;;;
; Fopen wrappers ;
;;;;;;;;;;;;;;;;;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files. */
allow_url_fopen = On

In most cases however, this won’t be allowed. You could try functions such as file_get_contents(), and parse the result afterwards – to have a similar working method such as fopen().



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.