Quantum key distribution (QKD) enables the establishment of shared keys between two distant users, Alice and Bob, based on the fundamental principles of quantum mechanics, and it has proven to possess information-theoretic security. In most of QKD systems, Alice and Bob require a shared reference frame, and real-time calibration of the reference frame increases system costs and reduces its performance. Fortunately, the reference-frame-independent QKD protocol has been proposed, overcoming reference-frame drift issues and receiving widespread attention. However, in practical QKD systems, the non-ideal characteristics of realistic devices introduce certain inconsistency between the theory and the practice. In real-world quantum key distribution systems, device imperfections can lead to security vulnerabilities, thereby reducing system security. For example, imperfections in the encoding apparatus at the source end may result in errors in the quantum states. The inherent defects in the detection part may cause after-pulse effects and dead-time effects, thus reducing the key rate. Therefore, in this work, we propose a practical state-preparation error tolerant reference-frame-independent quantum key distribution protocol by taking imperfections in both the source and the detectors into account. Moreover, a three-intensity decoy-state scheme for modeling analysis and numerical simulations is employed. In this protocol, we reduce the influence of state-preparation errors on the key rate by utilizing virtual state methods to precisely estimate the phase-error rate. Furthermore, by characterizing the effects of after-pulses and dead-time on the key rate, our protocol exhibits higher robustness and can effectively address issues related to detector imperfections. This approach can also be extended to other quantum key distribution protocols with higher security levels, such as measurement-device-independent quantum key distribution protocol and twin-field quantum key distribution, further mitigating the influence of device imperfections on practical implementation of QKD system. Therefore, our present work provide important reference value for putting the quantum key distributions into practical application.