Capt. James Rowell said deputies responded to reports of shots being fired at the school around 6:30 Friday morning.
When deputies arrived, they too heard the sound of gunshots.
Listen to the sounds yourself in the videos below.
Officials said students were on campus for athletic activities but no one was injured.
Students were evacuated and buses already on the way to school were diverted to a safe location.
Stay on top of breaking news stories with the ABC11 News App
Rowell said deputies swept the school but found no evidence that any shots had been fired.
They later located a water heater unit that was malfunctioning and making sounds similar to gunshots. School officials said the sound was coming from the heater's combustion chamber, which allows gas to come through.
"When it (gas) hits a release valve, it does sound like a weapon going off and it echoes through the chimney," Pender County Superintendent Steven Hill said.
Authorities stressed that since the machine sounded similar to gunfire, it was the right decision to treat the incident as if it were an active shooter situation.
"What I heard when I got here, sounded like gunfire, Pender County Sheriff Carson Smith said. "I don't want anybody to think the students overreacted. It was a gas combustion. It sounded just like gunfire."
"I also heard those shots," District Attorney Ben David said. "I can tell you, it absolutely sounded real. These young people did not overreact by immediately perceiving it as a threat and immediately doing what they are taught to do."
The faulty machine was located and fixed; officials said it should not cause further issues.
Following the incident school officials released this statement to ABC11:
"There was a report of an active shooter situation at Topsail High School this morning after noises were heard coming from the top of the building. Law enforcement responded immediately and it has been determined there is no shooter and no weapon."