Fatal error: Uncaught Error: Call to undefined function bcadd() in PHP

Was recently seeing this error popup in the NGINX error log. But I cannot see any problems in the website frontend. What’s the cause of this? And how to fix it?

Seems like you are missing the bcmath extension. You can install it using the following command.

sudo apt-get install php7.4-bcmath

Be sure to replace the version of PHP with the version you installed on your system.

Then also restart PHP if needed (mostly it won’t be necessary.)

sudo service php7.4-fpm restart

If it is still showing the error, you can restart NGINX using the following command to let the changes take effect:

sudo service nginx restart

Or even a complete system restart

sudo shutdown -r now