One of the problems that face the use of XLPE insulators is the appearance of defects. These defects appear during the manufacturing processes of the insulator, and one of these defects is air cavities or voids. The defects presence within the insulators of high voltage cables affects the distribution of the electric field within the cable layers. The distortion of the electric field due to the presence of air cavities is the main reason for the treeing appearance inside the insulator, which eventually leads to the emergence of partial discharges that reduce the life of the cable. In this study, the effect of the presence of an air cavity inside an XLPE insulator was studied by changing the dimensions of the cavity, that is, changing the ratio of the dimensions of the cavity parallel to the electric field and vertical to it and the effect of this on the value of the electric field in the center of the cavity. It was noted that the electric field in the cavity is higher than in the external electric field. The increase in the field in the cavity center does not depend on the cavity size, but rather on the ratio of the cavity dimensions parallel to the electric field to the vertical to it. The electric field enhancement factor was calculated based on the simulation results, which showed a reasonable agreement with the theoretical values.