Aspergillus flavus is a fungus notorious for contaminating food and feed with aflatoxins. As a saprophytic fungus, it secretes large amounts of enzymes to access nutrients, making endoplasmic reticulum (ER) homeostasis important for protein folding and secretion. The role of HacA, a key transcription factor in the unfolded protein response pathway, remains poorly understood in A. flavus. In this study, the hacA gene in A. flavus was knockout. Results showed that the absence of hacA led to a decreased pathogenicity of the strain, as it failed to colonize intact maize kernels. This may be due to retarded vegetable growth, especially the abnormal development of swollen tips and shorter hyphal septa. Deletion of hacA also hindered conidiogenesis and sclerotial development. Notably, the mutant strain failed to produce aflatoxin B1. Moreover, compared to the wild type, the mutant strain showed increased sensitivity to ER stress inducer such as Dithiothreitol (DTT), and heat stress. It also displayed heightened sensitivity to other environmental stresses, including cell wall, osmotic, and pH stresses. Further transcriptomic analysis revealed the involvement of the hacA in numerous biological processes, including filamentous growth, asexual reproduction, mycotoxin biosynthetic process, signal transduction, budding cell apical bud growth, invasive filamentous growth, response to stimulus, and so on. Taken together, HacA plays a vital role in fungal development, pathogenicity and aflatoxins biosynthesis. This highlights the potential of targeting hacA as a novel approach for early prevention of A. flavus contamination.