An aerosol-generating system comprising: an aerosol-generating device for receiving an aerosol-forming substrate and generating an aerosol from the aerosol-forming substrate, the aerosol-generating device comprising a rechargeable power source; a charging unit electrically connectable to the aerosol-generating device to supply power to the aerosol-generating device for recharging the rechargeable power source; and an electrical connector comprising: a first connector part comprising: a plurality of electrical contacts (43,44,45); and a first magnetic element; and a second connector part, releasably electrically connectable to the first connector part, the second connector part comprising: a plurality of electrical contacts (53,54,55), wherein at least one of the plurality of electrical contacts is a resilient contact that is actuable between an extended position and a depressed position and is biased to return to the extended position; and a second magnetic element, wherein: the aerosol-generating device comprises one of the first and second connector parts (40,50) and the charging unit comprises the other one of the first and second connector parts (40,50); and the first and second connector parts (40,50) are positionable in a first connection position, wherein: the at least one resilient contact of the second connector part is in the extended position; the first connector part is arranged in contact with the at least one resilient contact; the first and second magnetic elements are magnetically attracted to each other, and the force of the magnetic attraction between the first and second magnetic elements is greater than the force required to move the at least one resilient contact from the extended position to the depressed position. an aerosol-generating device for receiving an aerosol-forming substrate and generating an aerosol from the aerosol-forming substrate, the aerosol-generating device comprising a rechargeable power source; a charging unit electrically connectable to the aerosol-generating device to supply power to the aerosol-generating device for recharging the rechargeable power source; and an electrical connector comprising: a first connector part comprising: a plurality of electrical contacts (43,44,45); and a first magnetic element; and a second connector part, releasably electrically connectable to the first connector part, the second connector part comprising: a plurality of electrical contacts (53,54,55), wherein at least one of the plurality of electrical contacts is a resilient contact that is actuable between an extended position and a depressed position and is biased to return to the extended position; and a second magnetic element, a first connector part comprising: a plurality of electrical contacts (43,44,45); and a first magnetic element; and a plurality of electrical contacts (43,44,45); and a first magnetic element; and a second connector part, releasably electrically connectable to the first connector part, the second connector part comprising: a plurality of electrical contacts (53,54,55), wherein at least one of the plurality of electrical contacts is a resilient contact that is actuable between an extended position and a depressed position and is biased to return to the extended position; and a second magnetic element, a plurality of electrical contacts (53,54,55), wherein at least one of the plurality of electrical contacts is a resilient contact that is actuable between an extended position and a depressed position and is biased to return to the extended position; and a second magnetic element, wherein: the aerosol-generating device comprises one of the first and second connector parts (40,50) and the charging unit comprises the other one of the first and second connector parts (40,50); and the first and second connector parts (40,50) are positionable in a first connection position, wherein: the at least one resilient contact of the second connector part is in the extended position; the first connector part is arranged in contact with the at least one resilient contact; the first and second magnetic elements are magnetically attracted to each other, and the force of the magnetic attraction between the first and second magnetic elements is greater than the force required to move the at least one resilient contact from the extended position to the depressed position. the aerosol-generating device comprises one of the first and second connector parts (40,50) and the charging unit comprises the other one of the first and second connector parts (40,50); and the first and second connector parts (40,50) are positionable in a first connection position, wherein: the at least one resilient contact of the second connector part is in the extended position; the first connector part is arranged in contact with the at least one resilient contact; the first and second magnetic elements are magnetically attracted to each other, and the force of the magnetic attraction between the first and second magnetic elements is greater than the force required to move the at least one resilient contact from the extended position to the depressed position. the at least one resilient contact of the second connector part is in the extended position; the first connector part is arranged in contact with the at least one resilient contact; the first and second magnetic elements are magnetically attracted to each other, and the force of the magnetic attraction between the first and second magnetic elements is greater than the force required to move the at least one resilient contact from the extended position to the depressed position.