Calcutta, Lord of Nerves. A short story in which the author asks what would happen if you took a real-life wretched hive and added zombies and an animate statue of the destroyer goddess Kali.
In Dan Abnett's Gaunt's Ghosts novel The Armour of Contempt, the swelter decks. One gambling den there sets out to beat Merrt to death, and when Ludd interrupts, intends to kill him as well. Hark was there to back Ludd up, but as he was in the swelter decks, some soldiers thought they could Revenge their captain on Hark safely; fortunately for Ludd, he dealt with them quickly enough.
Han Dold City in Douglas Adams' Mostly Harmless, which seems to be controlled by "police tribes" which lay ambushes for each other, and in which bass players are machine-gunned for playing the wrong riff one too many times.
Sanctuary, the setting of Robert Asprin's Thieves' World series embodies this trope. The city of Sanctuary itself is a Wretched Hive (although sufficient wealth or power can get you a modicum of safety and luxury), while the area called The Maze is The City Narrows and the tavern called The Vulgar Unicorn is the Bad-Guy Bar
New Crobuzon from China Miéville's Perdido Street Stationandsequels blows most examples here out of the water in terms of sheer ugliness. It's ruled by vicious capitalists who ignore crime against ordinary citizens, but send death squads to deal with dissenters, essentially ensuring that the city stays a brutal lawless mess forever.
Michael Moorcock's Elric character was once compelled to visit a city called Nadsokor, also known as the "City of Beggars". This city's population consists entirely of those who are physically, mentally, and morally deformed.
The Dipple—a refugee camp featured in several novels, such as Catseye and Judgment on Janus. Its ugliness is thrown into sharp relief by the fact that it is located in Tikil, the only city on the pleasure planet of Korwar.
In her novel Operation Time Search the city of Atlantis is described like this. It's a Not-So-Safe Harbor ruled by evil demon worshipping priests, and the hero goes to a Bad-Guy Bar for information.
Discworld: Ankh-Morpork in the earlier books; The Shades turn this all the way past 11 up to 125, to the point where "a ghastly frieze of tortured silhouettes" on a wall is deemed less likely to attract attention than "fresh paint". And informing three very drunk Watchmen that they'd blundered into the Shades was enough to sober them instantly.
Havelock Vetinari seriously cleaned up the city, though, by legalizing the Thieves' Guild and putting them in charge of regulating the muggings. And the Watch became very efficient later under the influence of Captain Carrot and Samuel Vimes. To the point Ankh-Morpork is in the later books a bustling center of economic activity where, according to Going Postal, "being attacked while going about your lawful business in Ankh-Morpork was now merely a possibility instead of, as it once was, a matter of course." You can still get killed at night just by wandering in the wrong places, but the pragmatic Ankh-Morporkians consider this "suicide". And a sure sign of being either a tourist (and thus accidental) or Too Dumb to Live since if you're a local you ought to know better.
Subverted in Feet of Clay, which has a bar named "Biers", a bar for supernatural creatures which contains at least a dozen deadly creatures every evening, but which is perfectly safe for a blind old widow named Mrs. Gammage to visit every evening. The creatures even go so far as to act like bar regulars she remembers from before the bar became "Biers", and protect her when she is not in the bar.
Conan the Barbarian: The pirate town of Tortage in the Barachan Islands. And throughout almost all Conan media, Shadizar, otherwise known as Shadizar the Wicked, capital of Zamora, Crossroads of the World.
The X-Wing Series has Gavin Darklighter from Tatooine going to the underlevels of Coruscant and thinking that "if Mos Eisely was considered the armpit of the galaxy, this part of Coruscant could be considered anatomically lower and decidedly less hygienic." A few chapters on, Corran Horn, wandering around and not paying attention to his surroundings like an idiot, finds himself at a very low-level bar. He was a cop, and thinks to himself that his beat on Coronet City had seedy spots, but they appeared positively immaculate and safe compared to here. He'd chased fleeing Selonians through sewers with better atmosphere and more consistent lighting than this bar, the Headquarters.
This is at least how Winston and the party members view the Proles, due to party propaganda and the standard class warfare. To the Proles themselves, it's just your standard poor/working-class lifestyle, to the point that an older who remembers life before IngSoc considers there to be no real difference from his life before the revolution, save for the absence of a few novelties like top hats and coat-tails. And the Proles themselves are the lucky ones; Big Brother doesn't care so much if he doesn't consider you important.
Lampshaded in C.R. Jahn's Underground. The Twisted Spokes in an "Ultimate Biker Bar" which sells hard drugs and permits duals on premises.
The eponymous Domina City of the web-novel Domina. Genetically engineered monsters roam the streets, gangs use Bio-Augmentation to turn into vampires or demons, and if you can't get in contact with someone, it's safe to assume they're dead.
Any urban environment in William Gibson's novels counts as this, but particularly the settlements that each of his cyberpunk trilogies are named after: the Sprawl — a continent spanning enclosed megacity; and the Bridge, a lawless community built on the carcass of a crumbling Golden Gate Bridge. Idoru's 'Walled City', an online community comprised almost entirely of hackers and (modeled after the real life wretched hive, the Kowloon Walled City) might also count, despite being virtual.
Parts of Darwin, especially New Town and of Kansas City in John Birmingham's Angels of Vengeance
Old Undertown from The Edge Chronicles: polluted, impoverished, crime-ridden, full of thugs and cutthroats, and generally unpleasant. However, its also the beating heart of society on the Edge, and is at no point portrayed as completely inhospitable or beyond hope. Until the Rook Trilogy that is, when nearly half of it is destroyed and the rest becomes nearly dystopian. It eventually gets destroyed, which is probably a good thing.
The entire Roman Empire (with special mention given to the cities of Rome and Ephesus) is portrayed as this in The Mark of the Lion trilogy—sexual deviance and debauchery are the norm for all social classes, especially the aristocracy, infidelity, domestic abuse, and divorce are unremarkable, religious intolerance is rampant, murder is easily hushed up, and then there’s the Gladiator Games and the fact that the vast majority of citizens are totally accustomed to the violence, sometimes even bored by it.
If you ever end up on Barsoom, avoid the old cities like Torqas and Warhoon (especially Warhoon). They tend to be crawling with either Green Martians, white apes, or both. Phundahl and Toonol are also pretty horrible; the former is filled with religious fanatics, while the latter is populated by the closest Martian equivalent to Objectivists.
The city of Godwin in the Hostile Takeover (Swann) series is run by a mixture of armed gangs and literally feuding corporations. There is no law enforcement beyond what someone's willing to pay for.
In The Candlemass Road,The Disputed Lands are a lawless place inhabited by reivers and killers.
The Venus Prime series has Labyrinth City on Mars and Shoreless Ocean on Ganymede. The former is a corrupt frontier town being used as a battleground in a war between labor unions, while the latter is a hotbed of racism.
Mark Delewen And The Space Pirates has Mark qouting 'A wretched hive of scum and villainy' as he enters the Ondoog system; due to it housing a spaceyard that catered to criminals.
Ysai, the capital city of the planet Gammu from Heretics of Dune definitely counts. Miles Teg notes the development of the city was purposefully directed into something "worse than ugly", and Reverend Mother Lucilla is eventually driven to tears after seeing the corrupt, desperate and dangerously violent state of the city's inhabitants firsthand. Think about that for a moment. The city was so bad it made a Reverend Mother cry.