bang (or knock) your head against a brick wall doggedly attempt the impossible and have your efforts repeatedly and painfully rebuffed.
1995Jayne MillerVoxpop You're banging your head against a brick wall for years and still getting nowhere. It's soul-destroying.