Fused deposition modelling (FDM) 3D printing, as a supporting technology in social manufacturing and cloud manufacturing, is a rapidly growing technology in the era of industry 4.0. It produces objects with the layer-by-layer material accumulation technique. However, qualitative uncertainties are the common challenges yet. In order to assure print quality, studying the error causing parameters and minimizing their effects is important. This paper presents a feedback-based error compensation strategy, which integrates fuzzy inference system and grey wolf optimization algorithm. The objectives are twofold. First, the possible errors in FDM 3D printing are discussed in detail and optimal error causing parameters are obtained in percentage. This is used to understand the effects of the printing errors in every phase of the 3D printing process. From the nine optimization configuration trials used, Config-6 that has 100 number of iterations and 60 wolves is selected due to its higher convergence speed and best fitness value. The integral absolute error (IAE) is used as an objective function and the global minimum is achieved in the iteration interval [86, 100]. The outputs of this optimization problem is used to achieve the next objective. Second, a closed-loop quality monitoring approach comprising of inner-loops and an outer-loop is utilized. The three inner-loops are used to monitor the errors during pre-printing, printing, and post-printing, respectively. The outer-loop, on the other hand, is responsible for monitoring the aggregated errors in all the three 3D printing phases. The error compensation system simulation in Matlab is run for 10 seconds, and the results show that the "normal" range deformation factors are reached within less than 2 seconds for the inner-loops, whereas the outer-loop deformation factor is achieved within 7 seconds. The responses are within the acceptable time range.