The resources misallocation among firms is serious in China, our calculation shows it has resulted in the total factor productivity (hereafter, TFP) loss of over 200% and has been gradually increasing in recent years, based on the firm-level data from National Tax Survey database from 2007 to 2016. This paper further investigates empirically the impact of digital finance on resources misallocation, by measuring resources misallocation with firm’s capital deviation and labor deviation, as well as measuring digital finance with the number of searches for fintech keywords on Baidu's webpage. Results suggest that digital finance can significantly mitigate resources misallocation among firms to improve the aggregate TFP by redistributing resources from over-resourced firms to under-resourced firms, although it cannot improve the TFP within a representative firm. The findings remain robust after addressing the endogeneity and using alterative variables of digital finance and value of labor output elasticity. Moreover, digital finance can rectify the credit-market discrimination, where its mitigating effect on resources misallocation prefers to non-state-owned firms and small and medium-sized firms. However, traditional finance, as measured by the number of offline bank branches, can also optimize resources allocation, but this effect is gradually diminishing and it also fails to rectify the credit discrimination.