A search for the rare decays Bs0→τ+τ- and B0→τ+τ- is performed using proton-proton collision data collected with the LHCb detector. The data sample corresponds to an integrated luminosity of 3 fb-1 collected in 2011 and 2012. The τ leptons are reconstructed through the decay τ-→π-π+π-ντ. Assuming no contribution from B0→τ+τ- decays, an upper limit is set on the branching fraction B(Bs0→τ+τ-)<6.8×10-3 at the 95% confidence level. If instead no contribution from Bs0→τ+τ- decays is assumed, the limit is B(B0→τ+τ-)<2.1×10-3 at the 95% confidence level. These results correspond to the first direct limit on B(Bs0→τ+τ-) and the world's best limit on B(B0→τ+τ-).