The invention discloses an epoxy resin containing phenolic hydroxyl groups and a preparation method of a fire-retardant foam material based on the epoxy resin.The preparation method includes the specific steps that phenol and formaldehyde are synthesized into phenolic resin under the effect of a basic catalyst, the phenolic resin is then reacted with epoxy chloropropane for 2-5 h at 60-100 DEG C so that part of phenolic hydroxyl groups in the phenolic resin can be subjected to an epoxidation reaction, water and unreacted epoxy chloropropane are removed, and the epoxy resin containing phenolic hydroxyl groups is obtained, wherein the epoxide number of the epoxy resin containing phenolic hydroxyl groups is 0.19-0.32 mol / 100 g; then, the fire-retardant foam material is prepared with the obtained epoxy resin containing phenolic hydroxyl groups as the main body, wherein the fire-retardant foam material is prepared from, by weight, 3-8 parts of a surfactant, 80-100 parts of the epoxy resin containing phenolic hydroxyl groups, 4-10 parts of a foaming agent and 10-40 parts of a curing agent.The preparation method is easy and convenient to implement, the polyfunctional epoxy resin containing phenolic hydroxyl groups, epoxy groups, benzene rings and the like is prepared and has the advantages of phenolic resin and the advantages of epoxy resin, and the prepared epoxy resin foam material is excellent in fire retardance, uniform in foam density and low in water absorption and can be applied to the fields of energy saving and heat insulating, fireproof and fire-retardant materials and the like.