If you have ever had reason to say ‘I’m glad I didn’t get that job’ there are a potential number of reasons why you did.
You’re gut instinct when you left the interview was that you didn’t like the atmosphere, your potential boss seemed a pain, the role when described in greater detail to you wasn’t what you thought. A negative outcome in this situation is a good thing most likely !
Another reason for relief may be that you really hadn’t thought through what getting this job would mean in terms of your commute, leaving your current role, your career path. In this situation you have wasted your time and theirs. Learn from this and next time consider all aspects of a potential job move.
You really did want the job. It had your name written on it. You didn’t get it.
If you got to second/ third interview stage you were in the running to the end and I expect there was very little you could have done to affect the outcome. You gained wonderful experience which will stand to your performance at the next interview you do (because this is a performance). Try to critically review what went well and what could have edged the decision in your favour. Write down your thoughts.
If you didn’t get past first interview stage ask yourself ‘did I prepare well enough’ ?
Did you understand what the job entailed and what the company did ? Had you justified in your head why you were perfect for the role and then did you convince your interviewer of same. Had you prepared for all the usual questions and pre-empted some of the more awkward ones ? Did nerves affect your performance ? Lots and lots of questions which I expect you know the answers to and which you can right for the next interview.
As I said above, an interview is a performance (in my opinion of course) and rehearsal is key.