If you’re having trouble with UFW failing to block IP addresses, make sure the priority of your rules is correct.
To show the priority ordering of ufw rules, do this:
$ sudo ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] OpenSSH ALLOW IN Anywhere
[ 2] 80 ALLOW IN Anywhere
[ 3] 443 ALLOW IN Anywhere
[ 4] 22 DENY IN Anywhere
[ 5] 11992 ALLOW IN Anywhere
[ 6] 3306 DENY IN Anywhere
[ 7] {ipaddress} Anywhere DENY IN
My IP deny rule was failing on the web because it was placed last.