FormatException: SyntaxError: Unexpected end of JSON Input

EDIT: The below only worked for one upgrade now regardless, I am experiencing this error with the self updater.

I’m aware that Invoice Ninja hasn’t officially been updated for PHP8.1 but I just wanted to report that if PHP8.1 is set as the default for CLI (which will happen if PHP8.1 gets installed on a server) then the built in updater will fail with FormatException: SyntaxError: Unexpected end of JSON Input.

This probably makes sense since there would be syntax changes in PHP8.1 compared to previous versions but the reason for this error could be confusing if someone encounters it.

To resolve this and get the built in updater working again, I simply changed the PHP CLI version back to 7.4 by using sudo update-alternatives --set php /usr/bin/php7.4

PHP 8.0 would probably also work.

After setting this, the built in InvoiceNinja updater is working correctly for now.

Personally I think a message should be thrown to the user if InvoiceNinja detects PHP8.1 being used for InvoiceNinja at this stage as I’ve experienced multiple incompatibilities with it and InvoiceNinja. Is there an ETA for PHP8.1 support?


Thanks for reporting this!

cc @david

We can tighten the system requirement for the PHP version in the composer.json file. I haven’t looked into the exact issue with 8.1 yet. Most likely we’ll look into this with when we upgrade to Laravel 9 LTS.

sudo update-alternatives --set php /usr/bin/php7.4

worked for me, with this error. from .81. to .83.

These updates are a thrill ride.


Yes unfortunately there has been a few bumps in the road. As these pop up we’ll try and correct as best as possible.

I’m getting this error trying to go from .83 to .84 now, despite what I reported above…I’ll manually update and see if the improvements on the self updater help for any updates after that.

I get this error regardless of the PHP version now actually. Trying to update 5.3.84 to 5.3.85 and the self updater just gives me this syntax error. Permissions are all correct. @david any ideas?


Can you check the browser console as to what the server is returning.

Returning “500 (Internal Server Error)”

main.foss.dart.js?v=5.3.84:64957 POST:
main.foss.dart.js?v=5.3.84:64957 ## Confirm password: true, true, false, true, false
main.foss.dart.js?v=5.3.84:64957 ## 3
main.foss.dart.js?v=5.3.84:64957 POST:
main.foss.dart.js?v=5.3.84:83874 POST 500 (Internal Server Error)
io @ main.foss.dart.js?v=5.3.84:83874
e0C @ main.foss.dart.js?v=5.3.84:66645
(anonymous) @ main.foss.dart.js?v=5.3.84:148095
(anonymous) @ main.foss.dart.js?v=5.3.84:5487
$2 @ main.foss.dart.js?v=5.3.84:79640
$1 @ main.foss.dart.js?v=5.3.84:79634
AO @ main.foss.dart.js?v=5.3.84:80849
$0 @ main.foss.dart.js?v=5.3.84:80056
a9n @ main.foss.dart.js?v=5.3.84:5623
wH @ main.foss.dart.js?v=5.3.84:79976
$0 @ main.foss.dart.js?v=5.3.84:80020
eLX @ main.foss.dart.js?v=5.3.84:5655
eQB @ main.foss.dart.js?v=5.3.84:5657
$1 @ main.foss.dart.js?v=5.3.84:79580
f_d @ main.foss.dart.js?v=5.3.84:4374
(anonymous) @ main.foss.dart.js?v=5.3.84:4382
childList (async)
$1 @ main.foss.dart.js?v=5.3.84:79587
eaf @ main.foss.dart.js?v=5.3.84:5662
dih @ main.foss.dart.js?v=5.3.84:5773
wp @ main.foss.dart.js?v=5.3.84:80857
a9h @ main.foss.dart.js?v=5.3.84:79983
nW @ main.foss.dart.js?v=5.3.84:79981
am @ main.foss.dart.js?v=5.3.84:79894
fG @ main.foss.dart.js?v=5.3.84:79895
aht @ main.foss.dart.js?v=5.3.84:121344
dVY @ main.foss.dart.js?v=5.3.84:22749
nU @ main.foss.dart.js?v=5.3.84:95363
wE @ main.foss.dart.js?v=5.3.84:95364
oN @ main.foss.dart.js?v=5.3.84:95342
eA @ main.foss.dart.js?v=5.3.84:95343
NS @ main.foss.dart.js?v=5.3.84:102251
ad5 @ main.foss.dart.js?v=5.3.84:102532
(anonymous) @ main.foss.dart.js?v=5.3.84:4414
aoR @ main.foss.dart.js?v=5.3.84:97816
iE @ main.foss.dart.js?v=5.3.84:97820
ao0 @ main.foss.dart.js?v=5.3.84:98153
a9O @ main.foss.dart.js?v=5.3.84:98125
anY @ main.foss.dart.js?v=5.3.84:98088
qS @ main.foss.dart.js?v=5.3.84:97875
(anonymous) @ main.foss.dart.js?v=5.3.84:4415
aNw @ main.foss.dart.js?v=5.3.84:97777
$2 @ main.foss.dart.js?v=5.3.84:97789
K @ main.foss.dart.js?v=5.3.84:79255
ab2 @ main.foss.dart.js?v=5.3.84:97784
asS @ main.foss.dart.js?v=5.3.84:97782
qT @ main.foss.dart.js?v=5.3.84:96910
a0f @ main.foss.dart.js?v=5.3.84:96904
a0f @ main.foss.dart.js?v=5.3.84:125175
ad2 @ main.foss.dart.js?v=5.3.84:96895
bdV @ main.foss.dart.js?v=5.3.84:96886
Vz @ main.foss.dart.js?v=5.3.84:96884
aTL @ main.foss.dart.js?v=5.3.84:96880
(anonymous) @ main.foss.dart.js?v=5.3.84:4415
b8F @ main.foss.dart.js?v=5.3.84:1336
aYS @ main.foss.dart.js?v=5.3.84:74078
(anonymous) @ main.foss.dart.js?v=5.3.84:4415
$1 @ main.foss.dart.js?v=5.3.84:74247
$1 @ main.foss.dart.js?v=5.3.84:74217
$1 @ main.foss.dart.js?v=5.3.84:74090
f_d @ main.foss.dart.js?v=5.3.84:4374
(anonymous) @ main.foss.dart.js?v=5.3.84:4382
Show 31 more frames

There should be an error in storage/logs/laravel.log

Unfortunately there isn’t. I cleared the laravel.log, re-ran the self updater, it fails and there is nothing generated to laravel.log at all.

I also have this and checked my logs and nothing in it for this error.

@nickkilla @kylegp

Can you clear the contents of bootstrap/cache please

Let me know if this works, and what version you are upgrading from.

No difference in result even when clearing out the bootstrap cache folder.

Trying to update 5.3.84 to 5.3.85. As nickkilla said in the other thread on this forum, the last few updates I’ve had to do by uploading the zip manually. It was a few versions back that the self updater appeared to break due to this error and all my usual troubleshooting hasn’t gotten it working.

Same findings and same upgrade .84 to .85 but occurred on recent updates,


For those with this issue, I found that it was due to PHP’s memory limit being set to low. In my case, it was set to 128M while the invoiceninja self updater wants to use more than 128M for updating. This was causing the script to reach the limit and halt.

I found this by checking my apache error logs located at “/var/log/virtualmin/mydomain.com_error_log”

and saw the line “Got error 'PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)”.

To solve this issue, increase the PHP memory limit to something greater. I changed mine to 512M.

I’m using php7.4 with invoiceninja, so the below steps should be adjusted for whichever version you are using:

  1. Edit /etc/php/7.4/fpm/php.ini and change the line “memory_limit” to 512M instead of 128M or whatever it currently is. I use nano to edit it so it was nano /etc/php/7.4/fpm/php.ini. Save that file.

  2. Run sudo systemctl restart php7.4-fpm.service.

  3. Try the self updater again. Worked for me, no more issues with the built in updater.


So It seems I had that already changed. I went ahead and increased max timeout also. The update occurred but still got the error at the end and checking the logs I see

2022/05/12 04:15:16 [error] 64365#64365: *541 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xx.x.x.x, server: xx.xx.xx, request: “POST /api/v1/self-update? HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php-fpm.sock”, host: “xx.x.x.x”, referrer: “xx.xx.xx.xx”

Added this to the nginx site config, so will see how it is next update.

    location ~ \.php$ {

      fastcgi_read_timeout 180;

This worked for me. Thanks!