Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Wilby1976's avatar

Permission denied on storage/framework/views

ErrorException in Filesystem.php line 111: file_put_contents(/storage/framework/views/52d86faa5f6dc1e88cfc9b9cfb43277454118833.php): failed to open stream: Permission denied

I've tried every solution I could find. I've updated composer. I've updated the permissions to 777 on the storage and bootstrap/cache folders just to see if that does the trick. I've cleared the cache, dumped the autoload. I've tried everything and I still can't get my installation of Laravel to load.

I'm running a xenial vagrant box and it's Laravel 5.3.

Any help is appreciated. Thanks!

0 likes
44 replies
elmig's avatar

chown -r www-data:www-data *

or similar.

5 likes
Maelth's avatar

@elmig solve my problem but with R in uppercase

chown -R www-data:www-data *

inside project folder

1 like
Wilby1976's avatar

This didn't work. I'm still getting the same error.

Wilby1976's avatar

I also get a permissions error on the storage/framework/sessions folder

Wilby1976's avatar

I've tried all the solutions listed in that thread as well.

sudo chgrp -R www-data storage bootstrap/cache sudo chmod -R ug+rwx storage bootstrap/cache

Doing this did not work. I still get permission denied errors on both framework/sessions and framework/views

I'm at a loss here. Ugggghhh

gmann1982's avatar

try this

chmod -Rf 0777 storage

you may need to run it with as root

5 likes
gmann1982's avatar

are you running the command in the local machine or the vm? not sure it maps permissions over to the vm

Wilby1976's avatar
in Filesystem.php line 111
at HandleExceptions->handleError('2', 'file_put_contents(/var/www/eplaravel/storage/framework/views/52d86faa5f6dc1e88cfc9b9cfb43277454118833.php): failed to open stream: Permission denied', '/var/www/eplaravel/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', '111', array('path' => '/var/www/eplaravel/storage/framework/views/52d86faa5f6dc1e88cfc9b9cfb43277454118833.php', 'contents' => '<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel</title> <!-- Fonts --> <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css"> <!-- Styles --> <style> html, body { background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0; } .full-height { height: 100vh; } .flex-center { align-items: center; display: flex; justify-content: center; } .position-ref { position: relative; } .top-right { position: absolute; right: 10px; top: 18px; } .content { text-align: center; } .title { font-size: 84px; } .links > a { color: #636b6f; padding: 0 25px; font-size: 12px; font-weight: 600; letter-spacing: .1rem; text-decoration: none; text-transform: uppercase; } .m-b-md { margin-bottom: 30px; } </style> </head> <body> <div class="flex-center position-ref full-height"> <?php if(Route::has('login')): ?> <div class="top-right links"> <a href="<?php echo e(url('/login')); ?>">Login</a> <a href="<?php echo e(url('/register')); ?>">Register</a> </div> <?php endif; ?> <div class="content"> <div class="title m-b-md"> Laravel </div> <div class="links"> <a href="https://laravel.com/docs">Documentation</a> <a href="https://laracasts.com">Laracasts</a> <a href="https://laravel-news.com">News</a> <a href="https://forge.laravel.com">Forge</a> <a href="https://github.com/laravel/laravel">GitHub</a> </div> </div> </div> </body> </html> ', 'lock' => false))
at file_put_contents('/var/www/eplaravel/storage/framework/views/52d86faa5f6dc1e88cfc9b9cfb43277454118833.php', '<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel</title> <!-- Fonts --> <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css"> <!-- Styles --> <style> html, body { background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0; } .full-height { height: 100vh; } .flex-center { align-items: center; display: flex; justify-content: center; } .position-ref { position: relative; } .top-right { position: absolute; right: 10px; top: 18px; } .content { text-align: center; } .title { font-size: 84px; } .links > a { color: #636b6f; padding: 0 25px; font-size: 12px; font-weight: 600; letter-spacing: .1rem; text-decoration: none; text-transform: uppercase; } .m-b-md { margin-bottom: 30px; } </style> </head> <body> <div class="flex-center position-ref full-height"> <?php if(Route::has('login')): ?> <div class="top-right links"> <a href="<?php echo e(url('/login')); ?>">Login</a> <a href="<?php echo e(url('/register')); ?>">Register</a> </div> <?php endif; ?> <div class="content"> <div class="title m-b-md"> Laravel </div> <div class="links"> <a href="https://laravel.com/docs">Documentation</a> <a href="https://laracasts.com">Laracasts</a> <a href="https://laravel-news.com">News</a> <a href="https://forge.laravel.com">Forge</a> <a href="https://github.com/laravel/laravel">GitHub</a> </div> </div> </div> </body> </html> ', '0') in Filesystem.php line 111
at Filesystem->put('/var/www/eplaravel/storage/framework/views/52d86faa5f6dc1e88cfc9b9cfb43277454118833.php', '<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel</title> <!-- Fonts --> <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css"> <!-- Styles --> <style> html, body { background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0; } .full-height { height: 100vh; } .flex-center { align-items: center; display: flex; justify-content: center; } .position-ref { position: relative; } .top-right { position: absolute; right: 10px; top: 18px; } .content { text-align: center; } .title { font-size: 84px; } .links > a { color: #636b6f; padding: 0 25px; font-size: 12px; font-weight: 600; letter-spacing: .1rem; text-decoration: none; text-transform: uppercase; } .m-b-md { margin-bottom: 30px; } </style> </head> <body> <div class="flex-center position-ref full-height"> <?php if(Route::has('login')): ?> <div class="top-right links"> <a href="<?php echo e(url('/login')); ?>">Login</a> <a href="<?php echo e(url('/register')); ?>">Register</a> </div> <?php endif; ?> <div class="content"> <div class="title m-b-md"> Laravel </div> <div class="links"> <a href="https://laravel.com/docs">Documentation</a> <a href="https://laracasts.com">Laracasts</a> <a href="https://laravel-news.com">News</a> <a href="https://forge.laravel.com">Forge</a> <a href="https://github.com/laravel/laravel">GitHub</a> </div> </div> </div> </body> </html> ') in BladeCompiler.php line 116
at BladeCompiler->compile('/var/www/eplaravel/resources/views/welcome.blade.php') in CompilerEngine.php line 51
at CompilerEngine->get('/var/www/eplaravel/resources/views/welcome.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 45
at Response->setContent(object(View)) in Response.php line 201
at Response->__construct(object(View)) in Router.php line 1028
at Router->prepareResponse(object(Request), object(View)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53
Snapey's avatar

Is your views folder empty? I have had problems in the past where I uploaded a bunch of logs as a different user and then could not overwrite the file even though all the permissions were ok for the directory.

elieandraos's avatar

sudo chmod -Rvc 777 storage

sudo chmod -Rvc 777 bootstrap/cache

3 likes
Wilby1976's avatar

@Snapey - Yes the views folder is empty. This is definitely a permissions issue, although nothing I try works. @elieandraos - your solution did not work for me.

Wilby1976's avatar

[Mon Jun 05 15:19:39.515536 2017] [:error] [pid 1528] [client 10.0.2.2:53210] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/eplaravel/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/eplaravel/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/eplaravel/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)\n#1 /var/www/eplaravel/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#2 /var/www/eplaravel/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#3 /var/www/eplaravel/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#4 /var/www/eplaravel/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('error', Object(Symfon in /var/www/eplaravel/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107

Wilby1976's avatar
Wilby1976
OP
Best Answer
Level 2

Figured out the issue. I had to change the permissions for storage and bootstrap/cache on my local computer. I kept trying in vagrant but that didn't work for whatever reason.

4 likes
JavedBaloch's avatar

Try run

php artisan view:clear

This might help

17 likes
ioanandrei's avatar

Hello Sorry to post here after 1 year, but i have the same problem and i can't solve it. Can you eplain to me what you've doen?

Chofo7's avatar

you have to write the full path, example:

sudo chmod -Rf 0777 /var/www/html/blog/bootstrap/cache

sudo chmod -Rf 0777 /var/www/html/blog/storage

it works well

honore237's avatar

Try "chmod -R 777 ( to storage of your laravel app)" Like "chmod -R 777 blog"

Zayar's avatar

Thanks. I had the same problem as above and your solution worked.

My site is live on VULTR and it was working for all most a month now and suddenly this morning I had this issue.

Just curious why did it happen in the first place. Any Ideas?

protendai's avatar

I tried everything shown above but didnt work so i ended up deleting everything in this folder /storage/framework/views/ and it worked. This error started when i moved my app from another machine.

Snapey's avatar

This works if the cached view files are owned by a user other than the web server

FoxRocks's avatar

In case this helps someone else, my go-to solution on this is to set the file and directory settings, like so:

sudo find demo/ -type f -exec chmod 664 {} ; sudo find demo/ -type d -exec chmod 775 {} ;

Change the "demo" to your project directory. I typically get this error on a new project, or when I've cloned my repository into a new project folder on my server.

Abdul-Wahab-Abbasi's avatar

@FoxRocks i also getting same error i cloned the repo from github and set it up on my hostinger vps server i tried all the solutions mentioned above i m so tired now please help me u can visit my site "https://srv690180.hstgr.cloud/login"

error: file_put_contents(/home/user/htdocs/srv690180.hstgr.cloud/storage/framework/views/9ef2caa1f60ca2697fee5b6f3c39e67e.php): Failed to open stream: Permission denied

JussiMannisto's avatar

@Abdul-Wahab-Abbasi It's a permission issue, as mentioned multiple times in this thread.

The storage directory and all its files must be owned by the web server user. Do you know how file permissions work on Linux? Do you know how to use chown?

Abdul-Wahab-Abbasi's avatar

@JussiMannisto i tried below commands to resolve this issue

sudo chown -R www-data:www-data /home/wahab-ssh/htdocs/srv690180.hstgr.cloud/storage

sudo find /home/wahab-ssh/htdocs/srv690180.hstgr.cloud/storage -type d -exec chmod 775 {} ;

sudo find /home/wahab-ssh/htdocs/srv690180.hstgr.cloud/storage -type f -exec chmod 664 {} ;

php artisan cache:clear

php artisan view:clear

php artisan config:clear

:) but issue still not resolved

you can check "https://srv690180.hstgr.cloud/login"

JussiMannisto's avatar

@Abdul-Wahab-Abbasi You're changing the permissions of /home/wahab-ssh/htdocs/srv690180.hstgr.cloud/storage, but the error page shows a different path: /home/user/htdocs/srv690180.hstgr.cloud/storage.

Assuming that the path in the error message is correct, this command should be enough:

sudo chown -R www-data:www-data /home/user/htdocs/srv690180.hstgr.cloud/

When you run artisan commands as your own user, you may overwrite the file permissions. So don't do that. Whenever you run artisan commands, run them as www-data, e.g.

sudo -u www-data php artisan cache:clear

I always define an alias for that:

alias art='sudo -u www-data php artisan'

Then I can use it like this:

art cache:clear

Please or to participate in this conversation.