Iron bars
Iron bars are a dungeon feature represented by #.
They are never randomly generated in Vanilla NetHack. There are iron bars in the wizard, tourist and ranger quests.
You cannot walk through them or dig through them, and objects thrown through them have a chance of being stopped by the iron bars. Spells and ray/beam attacks (such as dragon breath) will pass right through them as if they weren't there. All monsters which are whirly, amorphous, phasing, tiny, or slithy and not large can pass through them,[1] including you if you are polymorphed into such a monster.
Probably a bug
If you are currently engulfed by a monster that can pass through them. The monster can still pass through them.
Variants
SLASH'EM
In SLASH'EM, iron bars may be found in some of the new levels of Sokoban. They are also found in Grund's Stronghold, and may comprise the walls of some maze levels, like in Gehennom. Iron bar mazes, are especially annoying during the ascension run.
Most creatures cannot pass through the bars, but a doppelganger character may still liquid leap through them.
UnNetHack
In UnNetHack, iron bars may be found in some of the new levels of Sokoban. Creatures are able to pass through Sokoban bars. Some are created around the exit if you are attempting to steal from the Black Market.
They sometimes are generated on room-and-corridor dungeon levels instead of doorways.
There is a small chance that levels in Gehennom may have iron bars instead of walls, making it difficult to hack a path.
Iron bars may be dissolved by a potion of acid,[2] acid breath (with a 20% chance),[3] and eaten by metallivores.[4][5]
SporkHack
In SporkHack, they are sometimes generated on room-and-corridor dungeon levels instead of doorways.