People feel lonely for a number of reasons, such as not having enough friends, not knowing how to be close to the people you know, or not being accepted by those you try to befriend.
Everyone experiences loneliness. Some humans are more socially accepted. Some who try to be social remain socially rejected, and some have difficulty even trying.
How to Deal With Loneliness
1) Realize that we all get lonely. It doesn't mean there is anything wrong with you. We're particularly prone to loneliness when we're making transitions, especially for the better. If you're changing, such as exploring new alternatives and paths for yourself, you're bound to get a little lonely as you look for people who share your new interests and thoughts. There is no guarantee however, that you will be successful at forming new relationships.
2) Call or get together with the people you know, even if they aren't who you want to be with right now. Human contact makes more contact easier. This includes your mother and the guy at the deli counter. Listen more than talk. Listening, and drawing people out will deepen your contacts more than just talking endlessly about yourself. Do not exhaust your existing connections; these are all you have at the moment.
3) Get involved in anything where you will meet people. If you are very shy, find a group for social anxiety, even if it has to be online (obviously it's better if it's not). Volunteering can help. But don't attend functions with the idea of making friends or meeting people. Being too demanding is a sign of loneliness. Try to go with no expectations whatsoever, and to enjoy yourself regardless of what happens.
4) Challenge yourself to take the initiative in social relationships whenever you can. You ask the person if they want to chat, get a coffee, whatever. Remember how much you like it when people are attracted to you. Remember though, that you are trying to make a place for yourself in another person's life. Do not think that just showing up will win you instant friends. It can be a long, painstaking process, and most people you meet already have their own friends and lives. You must always show interest in other people before they will show interest in you, if they ever do.
5) Take risks about revealing yourself. Say what's on your mind, if it seems at all likely the other person will be receptive. It can hurt when it backfires, but it's worth it a million times over if it works.
6) Remember that we are all alone inside our heads; we are born and die alone; it's nothing special. Every person who has ever lived has been lonely. Love wouldn't exist without loneliness to inspire it. Look at your loneliness with detachment.
7) Notice the difference between loneliness and solitude. Imagine this is the last day you will ever be alone. What would you do?
8) Join an online community. Sometimes it can help. If you're willing to help others as well as being helped yourself, check out the free Phone Buddies peer counseling community.
9) When feeling lonely, don't allow yourself to wallow in your loneliness. Do something, anything! Take a walk, ride your bike.
10) Do everything you would normally do with a partner or friend. Many times it isn't the partner or friend you are missing, but the activities and hobbies you shared. Take yourself out for a date. For example, if you would have gone out to dinner or to a movie on a date, then take yourself out to a movie or to a nice restaurant. Don't hold yourself back.