That describes an nginx config problem. First, is nginx running prior to running certbot renew ? Because it must be running before using Certbot with --nginx plugin like you do. Certbot will start a copy of nginx outside of systemd if it is not and this can cause problems.
Assuming so, what does this show?
sudo nginx -t
And, your Ubuntu version should easily support the snap install of Certbot. Your 0.40 version is very very old. See below for install instructions. Just follow them carefully.