I don't know if I've recommended Roam Research here before, it's a mental organizing tool for research that works well for my brain. They just took $9M in funding so I fully expect them to either not be around in 5 years or to make some compromises that make them fully unacceptable for me to use in 5 years. I am old enough to know that there is no middle ground. So I now retract any recommendations I had previously made.
This page includes many self hosted alternatives: https://github.com/brettkromkamp/awesome-knowledge-management
I also do not particularly enthusiastically recommend any of the self hosted alternatives I've evaluated, by the way. But I'm interested to hear from people who have tried one and successfully incorporated it into their knowledge management / research workflow.