500 Internal Server Error After Server Memory Upgrade

Version ie <v5.12.0>

Environment

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an Error Document to handle the request.

We host Invoice Ninja on a subdomain (ninja5.mydomain.co.za)
Our shared server was running low on memory and our website was experiencing crashes. We upgraded to the memory to 5gb more and changed the memory limit of php file in Cpanel for the subdomain as well as for the main domain, Therafter this problem started.

There are no errors in :storage/logs/laravel.log

Php Ver 8.2

I have logged in with Windows Powershell (ssh) and Ran the ff commands:

  1. php artisan migrate (this took about 30 minutes and then gave an error of Driver for PDO/SQL not found and this was then added in laravel log - I dont know how to resolve this but I checked that the php extensions for SQL and PDO were installed and loaded - besides this error was never written to logs previously)
  2. php artisan config:clear (successful)
  3. php artisan cache:clear(successful)
  4. php artisan route:clear (successful)
    php artisan view:clear (successful)
    ***These command took about 15 minutes each to complete

I made sure the correct permissions were on all the folders (755)

This is my ninja php file now:

display_errors = On
max_execution_time = 60
max_input_time = 60
max_input_vars = 5000
memory_limit = 2028M
post_max_size = 8M
session.gc_maxlifetime = 1440
session.save_path = “/var/cpanel/php/sessions/ea-php82”
upload_max_filesize = 6M
zlib.output_compression = Off

I have no idea where else to look or what else to do as iv spent the last few days of looking at every other possible way to try and fix this but to no avail

Hi,

Are there any details about the 500 error in the web server error logs?

Hi Hillel

Thank you for responding. No I have not seen any error logs on the server. I do have root access though. Do you know where in specific I can check for the errors

They may be here: /usr/local/apache/logs/error_log

Sat Jun 14 23:23:08.256893 2025] [core:error] [pid 1656253:tid 1656253] [client 41.144.32.142:5791] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/public/public
[Sat Jun 14 23:23:08.256957 2025] [core:error] [pid 1656253:tid 1656253] [client 41.144.32.142:5791] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/public/public
[Sat Jun 14 23:23:11.439385 2025] [core:error] [pid 1656451:tid 1656451] [client 41.144.32.142:21106] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:23:11.439430 2025] [core:error] [pid 1656451:tid 1656451] [client 41.144.32.142:21106] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:23:11.523232 2025] [core:error] [pid 1656252:tid 1656252] [client 41.144.32.142:5770] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/public/public
[Sat Jun 14 23:23:11.523282 2025] [core:error] [pid 1656252:tid 1656252] [client 41.144.32.142:5770] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/public/public
[Sat Jun 14 23:23:15.341798 2025] [core:error] [pid 1656256:tid 1656256] [client 41.144.32.142:5781] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:23:15.341842 2025] [core:error] [pid 1656256:tid 1656256] [client 41.144.32.142:5781] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:30:54.724248 2025] [core:error] [pid 1656253:tid 1656253] [client 41.144.32.142:27872] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/settings/company_details
[Sat Jun 14 23:30:57.605097 2025] [core:error] [pid 1657356:tid 1657356] [client 41.144.32.142:28533] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:30:57.605137 2025] [core:error] [pid 1657356:tid 1657356] [client 41.144.32.142:28533] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:30:57.690189 2025] [core:error] [pid 1656254:tid 1656254] [client 41.144.32.142:28523] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/settings/company_details
[Sat Jun 14 23:30:57.690239 2025] [core:error] [pid 1656254:tid 1656254] [client 41.144.32.142:28523] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/settings/company_details
[Sat Jun 14 23:30:58.938552 2025] [core:error] [pid 1656451:tid 1656451] [client 41.144.32.142:27881] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:30:58.938593 2025] [core:error] [pid 1656451:tid 1656451] [client 41.144.32.142:27881] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
[Sat Jun 14 23:30:59.018553 2025] [core:error] [pid 1656252:tid 1656252] [client 41.144.32.142:27887] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions.co.za/settings/company_details
[Sat Jun 14 23:30:59.018598 2025] [core:error] [pid 1656252:tid 1656252] [client 41.144.32.142:27887] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: https://ninja5.khuphulasolutions:

This was abt the best I could do to give you a quick answer as I had to copy from Terminal Windows and yheres 1000s of lines

Here’s what ChatGPT suggests:

Thanks for the detailed information — the issue is clear now. You’re dealing with infinite internal redirects in Apache, as shown in the error:

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error.

This is not a memory or PHP issue — it’s a misconfiguration, typically caused by:


:white_check_mark: Root Cause: Misconfigured DocumentRoot or .htaccess causing /public/public redirection loop

Your log mentions:

referer: https://ninja5.khuphulasolutions.co.za/public/public

This suggests that:

  • Your app is installed inside /public
  • But your web server is already pointing to /public as the root
  • AND .htaccess is adding another /public, causing the loop

:white_check_mark: How to Fix It

:hammer_and_wrench: Option 1: If your Apache is already pointing to /public

Make sure the .htaccess rewrite rule doesn’t redirect again to /public

Open the .htaccess file at the Laravel root (outside /public) — delete or disable any rules there.

Then, confirm your DocumentRoot is correct. In Apache config (or CPanel settings), it should be:

DocumentRoot /home/YOUR_USER/public_html/ninja5/public

Then the app should be accessed at:
https://ninja5.khuphulasolutions.co.za (without /public in the URL)


:hammer_and_wrench: Option 2: If Apache is not pointing to /public

If your DocumentRoot is /home/YOUR_USER/public_html/ninja5, and you must access the app via:

https://ninja5.khuphulasolutions.co.za/public

Then:

  • Your .htaccess rewrite rules inside public/.htaccess are correct
  • But you must not point the browser or links to /public/public

This is error-prone and not ideal — best to change the DocumentRoot to /public.


:magnifying_glass_tilted_left: Bonus: Check for Symlinks or Misleading Redirects

Sometimes shared hosting creates symlinks like:

/home/YOUR_USER/public_html/ninja5/public/index.php
-> ../../index.php (wrong!)

Make sure there are no extra .htaccess files causing unexpected redirects.


:wrench: Your Next Steps

  1. Confirm the DocumentRoot for the subdomain in cPanel:

    • Should be /public, not the base folder
  2. Remove /public from URL references

  3. Double check public/.htaccess looks like this (the default):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

If that’s in the root folder and not in /public, remove it — it’s redirecting /public/public/public.


:white_check_mark: Summary Fix

To fix the infinite redirect loop:

  • Set Apache’s DocumentRoot to /path/to/your/ninja5/public
  • Access site via: https://ninja5.khuphulasolutions.co.za without /public
  • Remove any .htaccess in root folder doing another redirect

Let me know your hosting setup (is it CPanel or custom Apache virtual host?) and I can give the exact steps.

Hosting Setup is Cpanel

Thanks — since you’re using cPanel, here’s exactly how to fix the Invoice Ninja infinite redirect issue:


:white_check_mark: Goal

Ensure that:

  • Your subdomain’s Document Root is set to /public
  • You don’t access the app with /public in the URL
  • There are no conflicting .htaccess rules adding another /public

:hammer_and_wrench: Step-by-Step Fix in cPanel

1. Check & Fix Document Root

Go to:

cPanel → Subdomains → Document Root

  • For the subdomain ninja5.khuphulasolutions.co.za, it may currently be something like:
    /home/YOURUSER/public_html/ninja5
  • Change it to:
    /home/YOURUSER/public_html/ninja5/public

:white_check_mark: This ensures Apache starts serving from the correct /public directory (Laravel’s entry point)


2. Remove Any /public in the URL

Stop visiting https://ninja5.khuphulasolutions.co.za/public — this will now loop.

Start using:

https://ninja5.khuphulasolutions.co.za/

If you see /public/public in the logs again after this, something is still wrong in the config or rewrite rules.


3. Delete Root .htaccess Redirects

In /home/YOURUSER/public_html/ninja5/ (the Laravel root folder):

  • If you have a .htaccess file redirecting to /public, delete it.

Example to REMOVE:

RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]

That rule was only needed before you pointed the DocumentRoot to /public. Now it causes a redirect loop.


4. Verify .htaccess Inside /public

Make sure you do have this file in /public/.htaccess (default Laravel):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>

5. Clear Laravel Cache Again

Just to be safe:

php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear

These should run quickly now if everything is configured right.


:white_check_mark: Done!

After this:

  • No more /public/public in logs
  • No 500 error
  • You access the site at: https://ninja5.khuphulasolutions.co.za/

If it’s still not working after this, I can help check .htaccess and folder paths line-by-line if you send them.

Hi Just to keep you updated, Iv done exactly as stated.

Im now at (1) php artisan config: clear which is now 10 minutes into the command.
As soon as I run all the php commands, Ill test and update you.

HI There! Yipeee Its working!! Thanks a million, I really appreciate all the help and effort!

Glad to hear it, thanks for the update!