When a confined program suddenly fails, the quick fix people reach for is disabling AppArmor. Complain mode is the better middle ground: the profile stays loaded, but it only writes down what it would have stopped.
The tools come in a separate package on Ubuntu:
sudo apt install apparmor-utils
sudo aa-complain /usr/sbin/nginx
sudo aa-status | grep -A3 complain
You pass the program, and the tool finds its profile in /etc/apparmor.d/, where the name is the path with dots instead of slashes, so usr.sbin.nginx. Now run the thing that was failing and read the kernel log:
sudo journalctl -k | grep 'apparmor="ALLOWED"'
In complain mode the lines say ALLOWED where enforce mode would say DENIED, together with the operation, the path and the profile. That tells you exactly which rule to add. When the profile is fixed, switch it back:
sudo aa-enforce /usr/sbin/nginx
I’d never leave a profile in complain mode and forget it. It offers no protection at all in that state, apart from explicit deny rules, which the manual says are still enforced. Write yourself a reminder, or check aa-status after the work is done. Also note that snaps manage their own profiles, so changes to those get overwritten on the next refresh.
Further reading: aa-complain(8) manual page, Ubuntu Server docs: AppArmor