500 Server Error - Viewing PDF and Creating Invoices on InvoiceNinja v5 Self Hosted

Which version are you using?

I had freshly installed v5.3.69, but that gave me a 500 error directly and didnt even let me hit the home page or install it. So I installed the last known working version for me, which was v.5.3.21 (by chance, and not by trial and error of all versions between them).

The issue is that while fiddling around with v5.3.21, curiosity got the better of me and I clicked “Force Update” on the health status page and it updated to v5.3.70 which straight up gave me a 500 error and I couldnt find any way to revert the upgrade.

@david do you have any suggestions?

@sebinmichael

most likely your system is not able to run the composer installation, in these instances, you’ll want to copy the full package

https://github.com/invoiceninja/invoiceninja/releases/download/v5.3.71/invoiceninja.zip

and overwrite your existing files (ensure you backup your .env file first!)

I would like to also chime in that I am receiving a 500 server error, and the logged error is:

mod_fcgid: stderr: PHP Fatal error: Trait ‘Awobaz\Compoships\Compoships’ not found in /home/user/website/app/Models/Company.php on line 29, referer: https://www.website.com/flutter_service_worker.js?v=5.3.68

Also with version 5.3.70. The way I do the updates is to overwrite the files with https://github.com/invoiceninja/invoiceninja/archive/refs/tags/v5.3.70.tar.gz

Noticed that a 5.3.71 version was just uploaded. I overwrote the files with 5.3.71 but still getting the same error

@Stevan

can you try overwriting with this file please

https://github.com/invoiceninja/invoiceninja/releases/download/v5.3.71/invoiceninja.zip

Ok, I will try it, thanks. But would like to point out that downgrading to 5.3.68 brings me back to operation. 5.3.69 is the version when I can no longer just extract the version.tar.gz files and keep running.

Edit: By “downgrading” I mean extracting the v5.3.68.tar.gz files to the website folder

Okay, so I unziped the invoiceninja.zip, rewriting all files. When I try to load https://www.website.com/update?secret=TheSecretForTheWebsite, it gives me a 500 error. But accessing www.website.com does load a page, but when I go to “about” it is still in 5.3.68, even though the VERSION.txt is 5.3.70.

I again unziped everything to the folder, overwriting everything, but still… for some reason the page “about” says 5.3.68, and the update?secrete page gives the 500 error. The error.log entry is the same as before. Not sure if I’m messing up somewhere, but if I am, not sure where

I deleted the folder, and unzipped invoiceninja.zip, inserted the .env backup, and that seems to get it running. Did I removed anything from the original files that I should replace from my backup to this new installation?

Unfortunately I can’t get any pdfs. It gives me a pop up that says Error 500: I ran php artisan optimize and completed successfully, but the error persists. I also did the update?secret page, and seems to have worked, but the pdf error persists.

@stevan

This makes sense. New packages were added in 5.3.69, so if your system pulls in the v5.3.69.tar.gz file it relies on your system being able to do composer install.

Some shared hosts do not allow the composer install command to run so the installation will fail due to missing packages. In these cases the larger invoiceninja.zip file is required as it contains the full system pre-built.

Ok. I believe I can install composer on my system (but I don’t have it right now). I will try to install composer an try again the update from 5.3.68.

When I did the fresh unzip and included the .env backup, I could run the 5.3.71, but could not get pdf working (even after php artisan optimize). What could be the culprit there?

I have installed composer, but still the extracting the 5.3.72.tar.gz gives me the 500 error. Do I also have to provide a composer command?

Edit: To clarify, I have a fully working 5.3.68 installation, and I try to update by extracting the 5.3.72.tar.gz file into the directory. When I try to access the site it gives a 500 error with error.log entry same as previously posted in this thread

@Stevan

If you use the .tar.gz file, then after extracting you need to run

composer install -o --no-dev

Happy to report that running the composer command fixed the installation. PDF creation working well too, and no whitelabel issue (with 5.3.73).

Previously I was not running the composser command and the update still worked. Should this command be run everytime I use the .tar.gz file regardless?

@Stevan

I think the issue is we haven’t updated packages for a very long time, i’ll need to consider pulling in the main package for all users so we don’t see this issue for users who cannot run composer install.

I think I recall reading from a post that the preferred way to update was to use the compressed files (I assume it was the source codes) and overwrite the files, not via the git pull method (and that was the method the internal updater currently used). Would you say that is still the case, I just have to run the composer command afterwards? Or I should try the git method? (FYSA, the internal updater was not working to update from 5.3.68 to 5.3.73, it gave a message box error and refreshed the page, without updating).

The compressed files are much smaller ~ 17mb, and are perfect for updates unless the subsystem cannot do composer install afterwards if the vendor packages have changed.

The nasty edge case we are seeing here is if composer install cannot run, the app breaks because the vendor packages are not available.

My thinking is we change this to point to the full package so whilst it is much larger, it improves to overall experience for all users.

I would avoid using git, we tried this previously and was not as reliable as this current method.

1 Like

Hi,
Thanks for this.
Overwriting with this file brought my site back to life, but PDF generation is still giving me a 500 Server Error.
I can confirm that both phantom as well as snappdf are causing this issue.
Further, even when I go to invoice design (HTML), it does not generate.
So I think it is an issue with the app itself, not the pdf engines.

I guess I have the same problem.
5.3.73 gives me an endless loading loop.

Will do a complete new install and report back if the problem is still there.

Update: After making a fresh install on a Ubuntu VM, the PDF problem is gone.

I wanted to report what happened lastnight.

I tried to copy over the previous copies. That was very unsuccessful. I have to do a complete new install.

Here was my steps:

Download with wget the zip file for the latest release.
Extracted in to /var/www/html
I had to run composer install -o --no-dev
Then I copied .env.example to .env
Then I created a key with artsian
Then I chown -R www-data:www-data .

Setup screen came up. It was an endless loop of the setup screen. So I manually made the .env file. There was no errors. I got in. Database still worked from 68 version. Client was working and all the other function was working except for PDF. It did matter if I use snappdf or phantomjs. I keep getting this error. Why is it calling localhost if that is not the app_url you place? This is where I am now. I can migrate again if you like to see what happens. But PDF are not working.

[2022-03-18 08:29:37] production.ERROR: file_get_contents(http://localhost/storage/JcwYAp1c9bp1jNC6mjWbA8RrCeBcPgZu/PViO2gZALI4ZiGVMSSTvKQuXvAespHtLFLXgIjsY.png): failed to open strea>
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/html/app/Models/Presenters/CompanyPresenter.php(69): file_get_contents()
#2 /var/www/html/app/Utils/HtmlEngine.php(419): App\\Models\\Presenters\\CompanyPresenter->logo_base64()
#3 /var/www/html/app/Utils/HtmlEngine.php(567): App\\Utils\\HtmlEngine->buildEntityDataArray()
#4 /var/www/html/app/Utils/TemplateEngine.php(175): App\\Utils\\HtmlEngine->generateLabelsAndValues()
#5 /var/www/html/app/Utils/TemplateEngine.php(147): App\\Utils\\TemplateEngine->entityValues()
#6 /var/www/html/app/Utils/TemplateEngine.php(84): App\\Utils\\TemplateEngine->replaceValues()
#7 /var/www/html/app/Http/Controllers/TemplateController.php(96): App\\Utils\\TemplateEngine->build()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\TemplateController->show()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(721): Illuminate\\Routing\\Route->run()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()