What if both pilots are locked out of cockpit? Anyone knowing the code (relief pilots, flight attendants, maybe air marshals) can unlock it. That being said, on the inside, there is a switch like this: In the “unlock” position, the door is unlocked and anyone can enter the cockpit.