Treat your mental health
A connection between UC and mental health issues that might also affect your sleep has been shown by research. Poor sleep quality and depression were linked in a 2018 research of 47 UC patients. Additionally demonstrated to interfere with sleep is anxiety related to UC.
Sometimes it's difficult to tell which came first between physical symptoms and mental health issues, similar to the chicken or the egg problem. However, it also suggests that improving your ability to deal with mental health issues may help you sleep better. Recommend consulting a professional, such as a therapist, for help if you're dealing with anxiety, depression, or any other mental health issue. They can help you in coping, which might also lead to better sleep.