Guide:Dungeon Guardian strategies

The Dungeon Guardian is the strongest monster in Terraria and spawns when you try to enter the dungeon before defeating Skeletron, or when failing to defeat Skeletron before dawn. There is little reason to fight him, except for the Bone Key he drops.

Terrain Preparation
As he will instantly kill you when he touches you the only way to defeat him is to outrun him. Therefore you have two good options for terrain. First is simply use the whole map, by using Gravitation Potions to move around. You will fall faster than him and you can move diagonally to go even faster. The second option is a very long (single-layer) Skybridge. You will be equally fast as the Dungeon Guardian when running horizontally. If you want to outrun him make a diagonal skybridge (any blocks except platforms work for this) or build the skybridge out of Asphalt.

Aside from that, if you want to 'summon' the dungeon guardian by entering the dungeon you need a way out of the dungeon. Easiest way is to simply dig straight down and use a Gravitation Potion to get up again.

If the player has access to the Mechanic and Steampunker it is possible to build a Teleporter arena (example). This can make the fight dramatically easier, especially if the Teleporters are automated with Timers. As the Mechanic is found in the Dungeon it is however likely that this requires the player to bring materials from a world where Skeletron has already been defeated.

Last of all, you need to be in a world where Skeletron has NOT been defeated.

Gearing Up
As the Dungeon Guardian will instantly kill you, your defense is entirely irrelevant (unless using the maximum defense available; more on this tactic below). For this reason, it is recommended that you use mobility accessories rather than defensive ones. Also, because its defense is so high that damage doesn't matter, there are only a few items which are actually useful.

Armor
If available use Frost armor, as the Dungeon Guardian is not immune against the Frostburn debuff, greatly increasing the damage. It also provides a good crit bonus. Another option would be Chlorophyte armor, as a full set summons a leaf that also shoots at the Dungeon Guardian and it also provides a crit bonus. Yet another option is to use Beetle armor with the shell along with defensive accessories and an Endurance Potion and Lifeforce Potion to give you a fairly good chance of surviving a hit from the dungeon guardian should it happen to hit you. You can also use Tiki Armor or Spooky Armor if you want to use minions.

Weapons
Ranged weapons are the only viable type of weapon for this fight. Furthermore the weapon should have a high firing speed. Recommended is any prefix that increases critical hit chance or firing speed.
 * Some high firing ranged weapons are Chain Gun, Gatligator, Megashark, Minishark and Uzi. Combine them with Crystal Bullet for additional damage from the released fragments, or Chlorophyte Bullets and a Chain Gun to deal damage at an insane rate.
 * Bows that may be useful are the Tsunami or Pulse Bow, due to them firing multiple projectiles. Combine them with Holy Arrows for more damage (which is mainly useful if you do not make use of the skybridge method).
 * The Piranha Gun is a very easy to use ranged, 'homing weapon', that deals significant damage.
 * Useful magic weapons would be Razorpine, Crystal Storm, Leaf Blower, Bubble Gun and, if you use the skybridge method, Blizzard Staff.
 * If you want to use melee damage based weapons using Vampire Knives, the Scourge of the Corruptor or the Flairon are possibilities.
 * Although most minions are useless, due to them being to slow the Optic Staff and Tempest Staff can be helpful, due to their minions shooting projectiles.
 * If you are playing with friends, take the Dungeon Guardian to spawn and fly in circles while attacking with Vampire Knives and let your friends use the Scourge of the Corruptor and blast tiny eaters at it.
 * If using Minions you can use the Optic Staff or Tempest Staff to do lots of damage while the player concentrates on dodging.

Accessories
Prefixes for accessories should be more critical hit chance or more movement speed.
 * If you do not use Gravitation Potions, Spectre Boots as well as a Shiny Red Balloon, or any upgraded version of those items. This will be needed when you reach the end of the skybridge to jump over the Dungeon Guardian when switching direction. Furthermore you need to be able to run and reach the horizontal speed cap.
 * If you do use Gravitation Potion some item to negate fall damage or provide running may still be useful.
 * If you use any type of wings, the Frog Leg is very useful because it provides 50% increased flight speed and range.
 * Black Belt or Master Ninja Gear give you a chance to dodge an attack. This is especially useful in combination with Turtle armor and Cross Necklace.
 * Destroyer Emblem and Eye of the Golem for their increased crit chance.
 * A Mana Flower, in case you use magic weapons.
 * Optionally a Depth Meter/GPS, so you can see when you move past the 0 depth line, causing the Dungeon Guardian to spawn.
 * With Minions you can use Pygmy Necklace, Necromantic Scroll, and a Papyrus Scarab for extra minions.

Potions

 * Gravitation Potions, in case you use that method.
 * Swiftness Potions and something to give you the Well Fed buff, to increase your movement speed.
 * Any Mana Potions if you use magic weapons.
 * Optionally some Rage Potions and potions that provide light, such as Hunter, Night Owl and Shine Potions.
 * A Summoning Potion can be used to allow the usage of an extra minion.

The battle
Basically you just need to keep running away, keep firing and make sure your buffs don't run out. If you set up everything correctly it just comes down to skill, while no real strategy is required.

You can use Hallowed Repeater with Heart Arrow as it can freeze the dungeon guardian. This will take about 45 minutes to defeat the Dungeon Guardian.