Under optimal conditions, a goldfish can live for about 10 to 15 years. Some goldfish have been known to live even longer. Proper tank maintenance, adequate space, a balanced diet, and good water quality are crucial for their longevity and health.