The invention provides an anti-inflammatory and antibacterial onychomycosis treating gel agent and a preparation method thereof. The gel agent contains the following substances: hydroxypropylmethyl cellulose, sodium carboxymethyl cellulose, glycerin, azone, miconazole nitrate, aloe oil, sea buckthorn fruit oil, white vinegar, a garlic extract, a sophora flavescens extract, a phryma leptostachya extract, a pepper extract, a stemona japonica extract, a folium artemisiae argyi extract, a kochia scoparia fruit extract, an impatiens balsamina extract, distilled water, ethanol with the concentration of 75%, urea, methylparaben and ethylparaben. Compared with the prior art, the gel agent provided by the invention has the advantages of quick absorption, good compliance, an exact effect of preventing and treating onychomycosis, efficacies of eliminating inflammation, resisting bacteria, improving the textures and colors of nails, treating beriberi and the like, and capabilities of significantly improving the onychomycosis of a patient and effectively improving the immunity.