The projectile may be cheap but there is also the problem of building a barrier that can withstand or contain the explosive power of the projectile. Having to rebuild the barrier repeatedly would be expensive too.
That is exactly the problem with rail gun beside the tremendous power that it required Here is the USNI article on railgun
Not only do the weapons require a tremendous amount of power
—
sometimes in short supply on naval vessels — the rails want to pull themselves apart every time the weapon is fired. In addition to the power requirements and the engineering task of keeping the weapon whole, the Navy also has had to develop a system to quickly pulse the energy through the rails to gain the velocity needed to reach supersonic speeds.
And it not going to be deployed anytime soon
The timing of the operational capability — in the 2020 to 2025 timeframe — suggests the Navy may look to include an EM rail gun on its next generation large surface combatant. The follow-on to the Arleigh Burke-class destroyers and the Ticonderoga-class cruisers is in its earliest phases of development and planned to start construction in 2028,
.