The short answer: Get Tesla or an accredited repairer to fix this, unless you have suitable accreditations Tesla will unlikely sell you the part to fix this yourself as it involves the DC charging system of the car, that said some owners have done this work themselves in the past so it’s certainly possible.
How much will Tesla charge?
Tesla will charge out of warranty repairs at £130.10 (correct as of October 2020) to fix this, this most likely is the easiest and quickest method of repair.
The part required is 1083168-00-A (Model S/X) (SERVICE KIT – SERVICE REPLACEMENT OF PIN CARRIER IN EU CHARGEPORT HARNESSES) which is £17 (correct as of October 2020), however, this is a restricted part as it’s to do with the High Voltage system so most likely only available to be ordered by a trained professional / Tesla Authorised Bodyshop.
Is this not a warranty repair?
It’s a hot debate whether this should be a warranty repair or not, given that most likely it requires an excessive knock to cause the damage Tesla will often argue it’s user error, however, if it’s a manufacturing defect it should be covered, if not, then it will be whether you can prove it was fit for purpose or not. More info about warranties / consumer rights etc here and also on the common issue page.
Can I repair myself?
Possibly but it’s highly recommended that you don’t, owners certainly have done this themselves but it’s not a recommended DIY job as you’re working near/on DC charge power which is incredibly dangerous.
Others have simply super-glued this back in place but your mileage may vary and you may very well end up causing more damage this way, as if you damage the rest of the charging port by misapplying glue then the cost of the whole assembly replacement runs up towards £450 or so (£300 for the part and £150 labour, as the full port unit is paired to the car so requires diagnostic time too whereas the socket itself doesn’t need the diagnostic work).