Home > Blockchain >  Laravel app not working after deploying on Heroku
Laravel app not working after deploying on Heroku

Time:02-24

I have a Laravel app working perfectly on my localhost, but when I deploy it on Heroku cloud, it gives the following error,

ErrorException: file_put_contents(/tmp/build_a3cd0b04/storage/framework/sessions/YZFia5zZhnq2Lz2jZmdD9uZKjiQUU9KnMmRU0oad): Failed to open stream: No such file or directory

I have tried changing permissions of the storage folder, clearing cache, etc., but nothing works. Any ideas, please?

CodePudding user response:

It looks like you are using the file driver. That isn't a very good choice on Heroku due to its ephemeral filesystem. It won't scale horizontally and sessions will be lost unpredictably (whenever your dyno restarts, which happens at least once per day).

I suggest using the Redis, Memcached, or database driver.

If you already have aa database, that driver is likely easiest. You can use the session:table Artisan command to generate a database migration for holding session data. Commit that migration, update your config/session.php accordingly, redeploy, and run your migrations.

I suspect the cookie driver would also work. Basically, you can use anything but the file driver (or the toy array driver).

  • Related