The most common cause of appetite loss in fish is stress. The stress from overcrowding or transitioning to a new aquarium can cause a fish to stop eating for more than two days.
Other signs of stress in fish include swimming near the surface of the water and gasping for air, hiding, wounds and disease. Before attempting any other change, make sure that the oxygen content of the water is high enough for the fish, that there is sufficient cover for them to feel relaxed and safe, and that they are not the targets of aggression. Illness and disease are major signs of stress; while fish are regularly exposed to bacteria, an unstressed fish generally has a strong enough immune system to resist most illnesses.
If a fish does not appear to be stressed but still refuses to eat, contact the store or breeder to find out what they fed the fish. Make sure the food is in the right location of the aquarium; a bottom-dweller is unlikely to travel to the surface to eat. Finally, some fish dislike pellet and flake foods and require frozen or freeze-dried brine shrimp, krill and other invertebrates. Larger carnivorous fish may also respond positively to a few feeder fish appearing during mealtimes.