Aaron Carter's plan to buy a gun got thwarted by a computer.
As we reported ... a 911 caller told cops Aaron tried to buy a gun but got turned down. We spoke to the manager at the Florida gun shop, who says the singer was automatically denied after his background check got flagged. It's unclear what triggered the alarm.
The staff also noticed Aaron's odd behavior -- he was jumpy, bragging about himself and hitting on girls at the shop. The manager said he appeared unhinged.
As we reported ... cops rushed to Aaron's house 3 times in a 24-hour span earlier this month after someone called fearing he'd relapse or hurt himself. Cops rushed to his house again Friday, and he finally decided to enter rehab.