AT HALF past two in the morning a dozen people queue in the freezing cold to get in to Tresor, a night club in a former power station in Berlin. In the sweaty, dimly lit interior, about 100 people are dancing to repetitive beats. Others sprawl on seats near the bar, clutching drinks or other people. The club, one of the first places in Germany to play techno music, seems as popular as when it was launched in 1991. But clubbing itself is on the wane.

After the fall of the Berlin Wall night clubs sprang up in that city in a moment of “cultural anarchy”, says Dimitri Hegemann, one of Tresor’s founders. They took over disused banks, warehouses and power plants. In the rest of Europe several “superclubs” had already opened in the 1980s, and more followed. In London, Fabric opened in 1999 in a former cold store; in Amsterdam, one started in a former print works. Smaller venues proliferated, too.

Since then, however, the party seems to be winding down. Between 2001 and 2011 the number of discotheken in the Netherlands fell by 38%. In Britain there were 3,144 clubs in 2005 but only 1,733 ten years later, says the Association of Licensed Multiple Retailers; in 2015 revenues were £1.2 billion ($1.7 billion), down from £1.5 billion in 2010. In Berlin, although the number of music venues has been stable at about 350 (120 of which are clubs), several long-established night spots have closed their doors.

Partly this is because most European cities are becoming nicer to live in. “Even in Berlin it is harder to find an unused space in the inner city,” sighs Sven von Thülen, a DJ who has compiled an oral history of clubbing. Clubs are being pushed farther out. Increasing rents are also a problem, says Lutz Leichsenring of the Club Commission, a German industry body, especially in places such as London where property values have soared.

Gentrification can muffle the high-decibel economy. “If there’s one complaint, then the whole circus starts,” says Eelko Anceaux of De Marktkantine, one of the handful of clubs that bucked the trend and opened in Amsterdam in 2014. It is possible to build good relations with neighbours, he says; his night club, like many new ones, doubles as a restaurant and hosts vintage markets, which makes it more acceptable to nearby yuppie families. Even so, middle-class residents’ complaints about noise and drunk or stoned revellers make the life of a club-owner far trickier.

As cities gentrify, local politicians are getting stricter about clubs. Madame JoJo’s, a burlesque bar in London’s Soho, had its licence revoked in 2014 after two bouncers brandished a baseball bat at a rowdy crowd. In December the owners of Fabric at last won a year-long court battle against Islington Council, the local borough, which wanted to introduce drug-sniffing dogs. Last year in Berlin two clubs were closed down for fire-code violations.

Increasingly, anyone who wants to open a club must have a business plan, says Mr von Thülen, rather than just an enthusiastic bunch of friends willing to party. Patience is also useful: it took Mr Anceaux four years to get his club open and another year to get a full licence.

This is boring. Let’s go to a gig Two big social changes are squeezing club owners still further. The first is that the youth of today are surprisingly abstemious. In Germany, Britain, Denmark and Spain the use of MDMA, or ecstasy, which makes bonding with strangers and dancing to repetitive thumping sounds far more enjoyable, has fallen among 15-34-year-olds (see chart). (Trends in the use of drugs less closely linked to clubbing, such as cannabis and cocaine, vary by country.) Heavy alcohol consumption has also fallen slightly among young people. Excessive drinking in Britain has seen a particular decline: between 2005 and 2013 the proportion of 16-24-year-olds who were frequent drinkers (defined as drinking alcohol on five days in the previous week) fell from 7% to 2%. Buying a drink in a club is “really expensive”, gripes Amanda, a university student from America in London. (In certain clubs “guys are douchebags”, she adds.)

The second trend is that big outdoor music festivals are replacing clubs. In 2014 around 130 festivals took place in Amsterdam alone. In Britain some 250 take place annually, up from 80 in 2004. Many people are saving up to go to two big festivals a year, rather than clubbing each month, thinks Iason Chronis, a DJ. The economies of scale of big festivals, in which a captive audience splurges on food and drink, make it easier for festival organisers to book big DJs such as Calvin Harris or Jamie xx. This, in turn, makes it harder for clubs to afford them.

The night mayor’s nightmares

Some cities are trying to halt the decline. In 2002, after a stricter pole-dancing law was introduced in Amsterdam, the post of a voluntary “night mayor” was created to lobby on behalf of the night-time club and entertainment industry. “Small events are like small business schools,” claims Mirik Milan, a self-proclaimed “rebel in a suit” who has held the post of night mayor since 2012. In London last year a “music venues task-force” set up by the fun-loving mayor, Boris Johnson, recommended that local authorities should take a more “balanced” approach to dealing with noise and that a night mayor should be appointed. In Germany Mr Leichsenring of the Club Commission sits on a working group for the Berlin chamber of commerce. These night-time champions may be able to achieve better relations between governments, neighbourhoods and clubs. But there is little they can do about the decline of 24-hour party people.