The local TRAIN station is BALSICAS

It is about 18km from San Pedro,  a Taxi  maybe 20 to 30 euro

Currently Train services are partly suspended due to a combination of line upgrades and weather damage to the ALICANTE line

However during normal times you can catch trains to MADRID  ALICANTE and BARCELONA  from BALSICAS

A link to search for services can be found here   TRAINLINE