# Mautic PHP permissiong file error middlewares.cache.php

**URL:** <https://forum.mautic.org/t/mautic-php-permissiong-file-error-middlewares-cache-php/23243>\
**Category:** Product Support\
**Created:** [March 23, 2022, 11:36pm UTC](https://forum.mautic.org/t/mautic-php-permissiong-file-error-middlewares-cache-php/23243 "2022-03-23T23:36:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![listin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/listin/32/5568_2.png) [@listin](https://forum.mautic.org/u/listin)\
**Post date:** [March 23, 2022, 11:36pm UTC](https://forum.mautic.org/t/mautic-php-permissiong-file-error-middlewares-cache-php/23243/1 "2022-03-23T23:36:27Z")

</div>

**Your software**  
My Mautic version is: 4  
My PHP version is: 7.4.28  
My Database type and version is: mariadb

**Your problem**  
My problem is: cannot access mautic anymore…  
If I try to access mautic using ip address I get error 500…

These errors are showing in the log:  
Looked at APACHE log:  
[Wed Mar 23 23:13:47.642678 2022] [proxy\_fcgi:error] [pid 10240:tid 140611096954624] AH01071: Got error ‘PHP message: PHP Warning - file\_put\_contents(/opt/bitnami/mautic/app/…/var/cache/prod/middlewares.cache.php): failed to open stream: Permission denied - in file /opt/bitnami/mautic/app/bundles/CoreBundle/Cache/MiddlewareCacheWarmer.php - at line 84PHP message: PHP Warning: file\_put\_contents(/opt/bitnami/mautic/app/…/var/cache/prod/middlewares.cache.php): failed to open stream: Permission denied in /opt/bitnami/mautic/app/bundles/CoreBundle/Cache/MiddlewareCacheWarmer.php on line 84PHP message: PHP Warning - include(/opt/bitnami/mautic/app/…/var/cache/prod/middlewares.cache.php): failed to open stream: No such file or directory - in file /opt/bitnami/mautic/app/middlewares/MiddlewareBuilder.php - at line 82PHP message: PHP Warning: include(/opt/bitnami/mautic/app/…/var/cache/prod/middlewares.cache.php): failed to open stream: No such file or directory in /opt/bitnami/mautic/app/middlewares/MiddlewareBuilder.php on line 82PHP message: PHP Warning - include(): Failed opening ‘/opt/bitnami/mautic/app/…/var/cache/prod/middlewares.cache.php’ for inclusion (include\_path=’.:/opt/bitnami/php/lib/php’) - in file /opt/bitnami/mautic/app/middlewares/MiddlewareBuilder.php - at line 82PHP message: PHP Warning: include(): Failed opening ‘/opt/bitnami/mautic/app/…/var/cache/prod/middlewares.cache.php’ for inclusion (include\_path=’.:/opt/bitnami/php/lib/php’) in /opt/bitnami/mautic/app/middlewares/MiddlewareBuilder.php on line 82PHP message: PHP Warning - Invalid argument supplied for foreach() - in file /opt/bitnami/mautic/app/middlewares/MiddlewareBuilder.php - at line 84PHP message: PHP Warning: Invalid argument supplied for foreach() in /opt/bitnami/mautic/app/middlewares/MiddlewareBuilder.php on line 84’

I do not have this file in cache, I did clear my cache so this might be the reason…

What can I do to fix this error… why is this triggering and how can I regain mautic access?

I see the issue, but how can I fix??

Thank you,

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 24, 2022, 1:50pm UTC](https://forum.mautic.org/t/mautic-php-permissiong-file-error-middlewares-cache-php/23243/2 "2022-03-24T13:50:49Z")

</div>

Cache needs to be writable by your apache user (typically www-data). Run this after you are done editing mautic config

```auto
chown -R www-data: var/cache
chmod -R u+w var/cache

```

And in addition to cache write permissions are also necessary on following folders:

- var/logs
- var/tmp
- var/spool
- app/config/local.php
- media/files
- media/images
