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

lukegalea16's avatar

PHP Exhausted Allowed Memory

On my online server I am getting this error AH01071: Got error 'PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vhosts/example.com/sub.example.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 870', referer: https://front.example.com/

I have replaced my original domains with example and front for the privacy concerns.

What could the issue be in this case? Everything was working fine - this just happened abruptly.

0 likes
5 replies
koramit's avatar

I run into this kind of error sometimes on my VPS with ram 0.5 or 1GB.

I think because the VPSs are share resources and I provision less memory.

Maybe restart or add more memory and see if it fix.

1 like
channaveer's avatar

Instead of increasing the memory globally in the php.ini file you can achieve the same inside your preferred methods like the following

public function store () {
    ini_set('max_execution_time', '300'); //For 5 minutes 300/60
    
    //Rest of your code
}
1 like
lukegalea16's avatar

Would allowing more execution compensate for the lack of available memory?

Snapey's avatar

install laravel debugbar locally and check memory usage on each route or request. Make sure your local test environment has a similar sized database so that the queries will contain similar data

You are hitting the phi.ini default of 128mb. You could just increase the setting, but it's better to see if you can reduce the ram requirements

1 like
lukegalea16's avatar

Thank you for the reply! For the time being I have fixed it by increasing the allowed memory size to 256M instead of 128M (default). This kept my website functioning for the time being and not cause problems to clients. I will definitely be testing @snapey 's suggestion however. This issue occurred out of the blue without changing the website code. The database experienced an increase in the number of entries however, so this might explain the need for this.

Please or to participate in this conversation.