MgB2 bulk sample with porous structure was produced by using the in-situ solid-state reaction method under argon (Ar) atmosphere of 10 bar. Elemental Er in powder form was doped into MgB2 with different compositions (Mg (1-x) Er (x) )B-2, where x=0.00, 0.03 and 0.05, in order to investigate the effect of rare-earth (RE) element Er on the structural and electromagnetic properties of porous MgB2. The Er-doped samples result in small grain size structure compared to the undoped one. The lattice constants a and c of the doped samples, determined from X-ray diffraction (XRD) analysis, increase with the increasing Er content, and consequently the superconducting transition temperature (Tconset) of MgB2, determined from resistivity measurements, is slightly suppressed. Also, the upper critical field (B (c2)), the irreversibility field (B (irr)) and the critical current density (J (c)) values are significantly enhanced in the doped samples. For the best sample (x=0.03), at 15 K under a magnetic field of 4 T, the J (c) value reaches 2.4 x10(4) A cm(-2), which is higher than that of the porous sample by an order of 10(3), and the B (irr) value at 20 K reaches 9.7 T. These results imply that the RE element Er fills the pores, enhances the density and the grain connectivity. Hence, the superconducting properties of the porous MgB2 sample improve by Er doping.