Was it a U.S. Carrier flight?
Those carriers are known to be particularly strict about this even if you are a higher paying customer (business and First class) and want to stretch your legs on a long flight or want to talk with a friend/family member. The suspicion is even worse if you appear Middle Eastern or of ambiguous racial appearance....sad, but true.
Which is why I fly international carriers since most have galleys wherever passengers can get up and help themselves with water or juice anytime on a long flight. Coach passengers cannot go to business or first (unless the flight attendant finds a reasonable reason to let them in for a short amount of time, at least) and going near the cockpit door is obviously a big no no.
Sounds reasonable, unlike the U.S. Carriers who hawk at me about getting up from my seat and stretching my legs

!!!!