Invoice Design - 500 Internal Server Error

I just finished a fresh installation (V5.3.55) today on Ubuntu 20.04.3. However, I’m having a problem with “500 Internal Server Error” whenever I try to access Invoice Design. This error will appear when I click on the “Customize & Preview” button.

Please advise.
Thanks!

@amisdar

Best to check the logs in storage/logs/laravel.log

Also, ensure that you have configured a API key using PhantomJS

https://invoiceninja.github.io/docs/self-host-troubleshooting/#phantom-js

Thanks for your reply @david

  1. I configured the API key using Phantom.JS as proposed but the same problem still occurs
  2. Below here is the log that appears in laravel.log whenever I click on "Customize & Preview, but I don’t have any clue how to fix it:

production.ERROR: file_get_contents(https://mydomain.ddns.net:8009/images/new_logo.png): failed to open stream: Connection refused {“userId”:1,“exception”:"[object] (ErrorException(code: 0): file_get_contents(https://mydomain.ddns.net:8009/images/new_logo.png): failed to open stream: Connection refused at /var/www/invoiceninja/app/Models/Presenters/CompanyPresenter.php:73)[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /var/www/invoiceninja/app/Models/Presenters/CompanyPresenter.php(73): file_get_contents()
#2 /var/www/invoiceninja/app/Utils/HtmlEngine.php(400): App\Models\Presenters\CompanyPresenter->logo_base64()
#3 /var/www/invoiceninja/app/Utils/HtmlEngine.php(534): App\Utils\HtmlEngine->buildEntityDataArray()
#4 /var/www/invoiceninja/app/Http/Controllers/PreviewController.php(421): App\Utils\HtmlEngine->generateLabelsAndValues()
#5 /var/www/invoiceninja/app/Http/Controllers/PreviewController.php(318):



#50 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
#51 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#52 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
#53 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#54 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Pipeline\Pipeline->then()
#55 /var/www/invoiceninja/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#56 /var/www/invoiceninja/public/index.php(57): Illuminate\Foundation\Http\Kernel->handle()
#57 {main}

It may help to add LOCAL_DOWNLOAD=true to your .env file and then run php artisan optimize

https://invoiceninja.github.io/docs/env-variables/

Thanks, @hillel, I really appreciate your feedback. By following your advice, I don’t get the 500 Internal Server Error anymore but now I have different problems. Sometimes the preview will work, and sometimes it doesn’t (Failed to load PDF document).

Tried changing the design option (ie: Modern, Business, Creative) from the drop-down menu and this error will appear randomly. If that happened, I will need to refresh my browser and start all over again.

Any idea? Thanks

Are there any related error in storage/logs?

Nope, no error in the logs. Anyway, I have changed the PDF Generator from “Phantom” to “Snappdf” and it’s working fine now.

PDF_GENERATOR=snappdf
LOCAL_DOWNLOAD=true

Thanks!