Your level of clarity regarding this issue is remarkable. Many people have difficulty with self-reflection. Being able to identify the problem is difficult for many. I would recommend seeing a therapist. It would be advantageous for several reasons, including additional insight and analysis of your situation.
Additionally, a therapist could teach you alternative ways to deal with stress. The fact that you engage in self-harm means that you lack effective problem-solving skills.
A therapist could facilitate the development of healthy interaction skills and analyze why you have difficulty connecting with others. While you may have accurately identified the problem, you don’t know how to fix it. Mental health professionals are trained to deal with these very problems.
In the meantime, try to assess and understand your fear of being vulnerable in relationships. By not allowing yourself to be vulnerable you are attempting to protect yourself from potentially being hurt but by closing down you inhibit the development of a meaningful relationship.
It might be helpful if you kept a journal and wrote about your feelings. Documenting the way in which you feel, can create a deeper level of awareness. The journal, in addition to therapy, could greatly assist you correcting this problem. Please take care.