The Direct Laser Writing (DLW) technique has become a well-established, flexible and multi-functional method of micro- and nano-technology. A DLW system, mainly containing blue light writing module and red light autofocus module, is established and efficiently applied for the fabrication of diffractive optical elements (DOEs). In the DLW system, the stability of the writing beam is always a concern. Although the autofocus module is employed to eliminate the influence of the drifting focus point resulting from ambient vibration, the inherent defocusing error still has a serious impact on the lithography accuracy of the DLW system. As the refractive index of the lithography objective lens with a high numerical aperture (NA, 0.9) for blue light (405nm) differs from that for the auto-focus red light (650nm), the focal planes of the two beams will not coincide. Furthermore, the two beams can’t be mounted seriously parallel to the axis of the objective lens in practice. The misalignment will impact the location of the focus point axially and laterally. The above defocusing error is determined experimentally, and then is pre-compensated, which improves the fabrication accuracy dramatically. The relationship between defocusing amounts and line widths of the stripes is obtained, which can be used for writing gratings with different line widths. A 100×100 mm sized fused-silica grating with a period of 2 μm is obtained with the DLW system, and some microscope images are presented to show the effectiveness of the error-eliminating methods.