The invention relates to a drug delivery device for administering a drug, comprising: a body adapted to retain a cartridge containing a drug, at least one electrical unit (EU) and a port for electrically contacting the electrical unit (EU), an adapter for attaching an injection needle to the drug delivery device, a safety mechanism (S1 to S6) arranged to prevent access to the port whilst an injection needle is in fluid communication with the cartridge and arranged to prevent establishing a fluid communication between an injection needle and the cartridge whilst the port is accessible.