That error usually has something to do with your Internet connection. You need to be using a fast Wi-Fi or an Ethernet connection. Otherwise, the connection may time out. This is especially true for slow Wi-Fi connections.
Do you happen to know if the Recovery HD is still on the disk and working? Test for it by trying to start up from it:
Boot from the Recovery HD
- Restart the computer.
- Immediately after the chime press and hold down the "COMMAND" and "R" keys together.
- Release the keys when the Apple logo and progress bar appear.
- Upon completion, the Utility Menu should appear.
If this works, then continue.
Install El Capitan or Later from Scratch
- Select Disk Utility from the Utility Menu and click on Continue button.
- When Disk Utility loads select the volume (indented entry, usually Macintosh HD) from the Device list.
- Click on the Erase icon in Disk Utility's main window. A panel will drop down.
- Set the Format type to APFS (SSDs only) or Mac OS Extended (Journaled.)
- Click on the Apply button, then wait for the Done button to activate and click on it.
- Quit Disk Utility and return to the Utility Menu.
- Select Install OS X and click on the Continue button.
This will install the version of OS X you had installed.