The city of Pensacola, Fla., was hit with a cyberattack, shutting down much of the city computer network, days after a Saudi air force student opened fire at a military base there.

“The city of Pensacola is experiencing a cyberattack that began this weekend that is impacting our city network, including phones and email at City Hall and some of our other buildings,” Pensacola Mayor Grover Robinson said at a Monday briefing.

The mayor said he didn’t know if the attack was connected to Friday’s shooting, when a Saudi flight student opened fire in a classroom at Naval Air Station Pensacola before he was shot to death by authorities.

The Federal Bureau of Investigation is investigating Friday’s shooting. It couldn’t be determined if the cyberattack had any impact on the investigation.

The FBI in Jacksonville said it was aware “of a potential cyber related incident” and “are providing resources to assist,” according to a tweet on Monday afternoon. The FBI field office wasn’t immediately available for comment.

City emails, phone lines and 311 customer services have been affected, Mayor Robinson said. Payments for the city’s sanitation and energy services were also affected. “I want to be clear, 911 and emergency dispatch operators are not impacted,” he said.

The cyberattack first occurred early on Saturday, Mayor Robinson said. He didn’t specify if there was a request for a ransom, often known as a ransomware attack.

“We have received information that the shooter was active on social media, but we cannot yet release any specifics. A suspect’s digital footprint, to include use of social media, is pursued in these types of investigations,” said the FBI’s Jacksonville office on Twitter Monday.

On Monday, the U.S. Navy said that five of the eight people injured in the shooting rampage at the Pensacola Naval Air Station had been released from the hospital. The other three are in stable condition, the Navy said. Three sailors were killed in the attack. At the time of the shooting, the gunman was a qualified pilot and was learning the basics of how to fly a F/A-18, a Super Hornet tactical fighter jet, Pentagon records show.

“I definitely understand that all of that is on our minds and that the public has those questions,” Kaycee Lagarde, the city’s spokeswoman, said of any connection between the cyberattack and the shooting at the Naval base on Friday. “Unfortunately it’s too early to speculate or tell if those two are related,” Ms. Lagarde said according to a Facebook live interview with a local Pensacola TV station.

“Our IT department is still working through it and as a matter of security we don’t want to provide other details and open us up to any other threats,” Ms. Lagarde said in the brief video.

“As a precaution we did notify Homeland Security, the FBI and Florida Department of Law Enforcement,” Ms. Lagarde said, adding that the attack occurred at 1:30 a.m.

It couldn’t be determined when the city would get its various affected services back online.

—Nancy A. Youssef contributed to this article.

Write to Talal Ansari at Talal.Ansari@wsj.com

Copyright ©2019 Dow Jones & Company, Inc. All Rights Reserved. 87990cbe856818d5eddac44c7b1cdeb8