Vet trip to make sure she doesn’t have a UTI or something else going on.
How many litterboxes does she have? Is she spayed? Is there any way she could have been ambushed leaving the box? Have you used any particularly smelly cleaning solutions near the litterbox? Do you scoop it regularly?
It sounds like he needs to go to the vet to be examined. Dependent on his age and other health issues he may need blood work, x-rays and/or have his urine checked.
Good Luck
Dr D