There is some possibility you have insect or spider web issues in the burner tube forcing the gas to come out the air intake after the gas orifice. The gas has to have a proper place to burn, and if insects or mud daubers have filled it, the gas will come out where it can, causing flames in strange places. Clean the burner tube completely and the tube which runs through the water heater itself.
What confuses me is that you say you had a flame on the supply side of the gas valve. If you really mean that, sounds like a loose fitting.