In order to accurately predict geomagnetic storms, we exploit Elman recurrent neural networks to predict the D-st index one hour in advance only from solar wind data. The input parameters are the interplanetary magnetic field z-component B-z (GSM), the solar wind plasma number density n and the solar wind velocity V. The solar wind data and the geomagnetic index D-st are selected from observations during the period 1963 to 1987, covering 8620h and containing 97 storms and 10 quiet periods. These data are grouped into three data sets; a training set 4877h, a validation set 1978h and a test set 1765h. It is found that different strengths of the geomagnetic storms are accurately predicted, and so are all phases of the storms. As an average for the out-of-sample performance, the correlation coefficient between the predicted and the observed D-st is 0.91. The predicted average relative variance is 0.17, i.e. 83 percent of the observed D-st variance is predictable by the solar wind. The predicted root-mean-square error is 16 nT.