Me and my friend are trying to play Minecraft together. But as it seems, I can't connect to my own Minecraft server but my friend can. I have allowed it in my firewall among opening some ports in my router as well.
I'm hosting the server from the same computer I'm playing from. What can cause this and how can this be fixed?

What IP are you connecting through? There are are 3 or 4 ways to do this.

localhost can do, or connecting through your port directly. localhost:25565

Also you can use your computers IP address. To find this, go to command prompt and type in ipconfig and click enter. Find your IP address, it should look something like IPv4 Address: ###.###.###.###. Except their will be your IP address there. Type in your IP address and you can optionally add the port number to this one also. 25565.

The last way is through your computer's IP. You can find it here. Again you can type that IP in and also you can connect with just that or you can add the port again. 25565

The first two options are only used if the server is run on your computer. The port can be binded to other port numbers. I could allow my Minecraft server on port 230467 if I wanted to. That only means people would have to type in this instead of my normal IP, My.IP:230467. Make sense? Need to know anything else?
Also, check all your ports. Make sure they're open on the router itself, not just on your computer.

If someone posts something like this, I apologize. I have been distracted and didn't get a chance to post it sooner.

EDIT: It would really help if you tell us what pops up when you try connecting.