My 4 year old UPS (uninterrupted power supply) hasn't been getting charged for the last few months. I have searched a lot on Google but haven't found any solution to make it charge again.
How do I fix my UPS
Replace the battery/batteries. Batteries don't live forever, and UPSes in general kill batteries faster than some other services, due to cost-cutting in the charger design and/or focussing on getting the battery recharged as fast as possible after an outage.
UPS batteries usually need to be replaced on no more than a 3-year cycle, in my experience. Life may be improved somewhat if you have the space (and lack of children) to keep the batteries near but not in the UPS case, as many UPSes run hot, and heat is not good for battery life.
Warning/note - if you don't buy generic batteries, you may find that "new replacement batteries from your UPS brand" cost more than a new UPS. Shop wisely.