Troopers went to the 300 block of Maryland Avenue about 8 p.m. Monday after residents in the apartment called police.
The residents told police two men knocked on their door and pulled a gun, demanding to be let inside.
Police say the resident tried to knock the gun away while closing the door and a friend inside came to help slam the door shut. The two were able to close the door and lock it.
The two men outside kicked on the door but fled in a black Pontiac Sunfire when they couldn't get in.
You can get the latest crime statistics from the Philadelphia Police by CLICKING HERE for the force's crime data mapping site.