When kept in captivity, goldfish live anywhere from a few months to 45 years depending on the size of their habitat and how well they are cared for. Goldfish kept in bowls have the shortest lifespan; with proper cleaning and feeding, they can survive for about five years.
Goldfish do not survive long in bowls because the lack of a filtration system allows ammonia and nitrite to build up, which is poisonous to the fish. Goldfish that are kept outdoors in a pond and fed the proper diet live an average of 20 years, and in China, goldfish have been recorded to live more than 40 years. In aquariums, goldfish live an average of 10 years as long as they are not overcrowded.