Fish crowding the surface and gulping is almost always a cry for oxygen. The two causes that matter are low dissolved oxygen and ammonia poisoning, and they need different fixes, so read the tank before you act.
First, rule out normal behavior
Some fish visit the surface on purpose. Bettas and gouramis breathe air through a labyrinth organ, so a quick trip up is healthy. Fish also learn to beg at the top where food appears. Worry only when several fish hang at the surface constantly with their gills working hard.
Low oxygen
Warm water holds less oxygen, so this spikes in summer or near a heater set too high. Overstocking and poor surface movement make it worse. The fix is fast: point your filter outflow to ripple the surface, add an air stone, and drop the temperature a degree or two if the tank is running hot. Surface agitation is what actually oxygenates water, more than bubbles themselves, since gas exchange happens where water meets air.
Ammonia or nitrite poisoning
If oxygen looks fine and fish still gasp, test the water. Ammonia or nitrite above zero burns the gills, and damaged gills cannot pull oxygen even from well-aerated water, so the fish suffocates in a full tank. This is common in a tank that was never cycled or was recently scrubbed too hard. Do a 30 to 50 percent water change now, then keep testing daily. A brand-new tank doing this is showing classic new tank syndrome, and the real fix is patience plus cycling the tank properly.
Read your water before you guess
Guessing wastes the time your fish do not have. A liquid test kit tells you in five minutes whether this is an oxygen problem or a poisoning problem, and understanding your water parameters tells you what the numbers mean. Aerate for low oxygen, water-change for high ammonia, and confirm which one you have before reaching for either.