Yes—but not in every case. In many cities, urban trash cans do have some kind of locking or restricted-access mechanism, especially public bins in busy areas, parks, transit stops, and downtown streets. The goal is usually not to stop a determined dumpster diver; it is more about stopping people from stuffing household garbage, business waste, or bulky items into a small public litter bin. That kind of misuse fills bins fast and creates overflow, smells, pests, and extra collection costs.
The locking mechanism can take different forms. Some bins have keyed service locks that only sanitation staff can open. Others use tamper-resistant latches, internal gravity flaps, push doors, or narrow openings that make it hard to force a large bag into the bin. Some solar compacting bins and underground containers also have locked access doors. But plenty of ordinary street bins do not lock at all—cities often want them easy to use so people do not toss litter on the ground.
Locking has trade-offs, too. A bin that is too hard to use may get trash left beside it, and locked public bins can frustrate residents if access is unclear. So the design usually balances deterrence with convenience: restricted openings for everyday litter, locked service doors for maintenance, and larger locked containers for neighborhoods. So the short answer is: yes, many urban trash cans have locking mechanisms, but it is not universal. It depends on the city, the bin type, and what kind of dumping the city is trying to prevent.