Hi fishlover! Welcome to the forum
Firstly I am extremely impressed at the age of your fish, you must have a tough little cookie there! Generally goldfish need larger tanks than 30 litres, as it helps provide more space for growth and the temperature/water quality can be easier to manage, so just keep it in mind for any future goldfish buddies you'd like to keep
Generally bad water quality can result in illness or bad health, I'd definitely suggest getting your water tested at a local pet store, they'll often do it for free, so you can see if there is any ammonia or nitrite present and also find out what your nitrate level is.
Are there any physical changes to the fish? Anything unusual you can spot?
Also how often and how large do you do water changes?
Generally I'd recommend 50% of the tank once a week.
It might be that he is so old, it is his time to go, but get the water parameters checked and we can take it from there