Studying the long-time solution behavior of the Korteweg-de Vries (KdV) type equation with a periodic force acting at one end of the long channel is important for simulating the blood flow in artery driven by heart pulses. It is of great interest to develop an accurate numerical method for solving the forced KdV problem. In this article, we present the following methods to obtain an accurate approximation to the solution of KdV problem.•An accurate compact finite difference scheme is proposed for solving the above forced KdV problem with fourth-order accuracy.•An absorbing boundary condition at the right end of the interval is used to avoid the wave reflection.•The stability of scheme is proved by the von Neumann method and then tested by three examples. Results show that the method provides an accurate solution, and the wave propagates without reflection.