There are a least 4 neighborhoods to go to on a night out, namely Barrio de las Letras, Malasaña, Chueca, and Salamanca.
Barrio de las Letras is a few steps away from the famous Puerta del Sol it attracts mainly tourists, Malasaña has more of a bohemian and creative vibe that mainly caters to the locals. If you are part of the LGBTQ community, there is a place for you. Do not miss out on the Chueca district. In case you fancy something a bit more upmarket, have a wander round the Salamanca neighbourhood
Similar Questions: Is there a party street in Madrid? Where are the party zones in Madrid?, Where to party in Madrid?