Could you hit a railgun with a railgun? Why wouldn't countries build massive anti-ship railguns to prevent any such ship from getting even close to their naval facilities?
"Smaller than a missile". You could, but it's harder.
(Granted, it's more anti-missile than anti-bullet)