Skip to content
Advertisement

Laravel error: file_put_contents failed to open stream: No such file or directory

I have uploaded my Laravel project to shared hosting, but upon navigating to the website, i am getting the following error:

file_put_contents(C:UsersusernameDocumentsProjectNamesitestorageframework/sessions/MCjepvHYO7Ee7RAjHmY4azKuQx97TwrrkOw288W3): failed to open stream: No such file or directory

It seems like it is pointing to a local folder. What can I do to resolve this?

Advertisement

Answer

It turns out I needed to clear the Laravel cache on the server. I added the following to my routes/web.php file to run the command on my hosting server:

// Clearing Laravel Configuration Cache
Route::get('/clear-cache', function() {
    $exitCode = Artisan::call('config:clear');
    $exitCode = Artisan::call('cache:clear');
    $exitCode = Artisan::call('config:cache');
    return 'DONE'; //Return anything
});

And then navigated to mywebsiteurl.com/clear-cache to run the commands. Once it was done, I received a 500 error. After that, I was able to navigate to mywebsiteurl.com and my website loaded as expected.

I got the answer from the one accepted here: file_put_contents(C:storageframeworkviews/27f511f5644086daa68b2cf835bf49f5148aba43.php): failed to open stream: No such file or directory

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement