Are you sure the radiator fan in turning? That’s the first thing to check. When you hear it come on, get out, pop the hood, and make sure it is turning as fast as it should be.
A cooling system that is failing will show these symptoms. Idling taxes the cooling system more than driving, as there is no air flow due to the car moving to cool the radiator. And turning on the headlights puts a bigger mechanical load on the engine, which makes it heat up faster.
If it turns out not to be a faulty fan or fan temp switch, cooling problems can be caused by underfilled engine coolant due to a leak or a seep, a faulty thermostat, a faulty water pump, a faulty guage, air in the cooling system (suspect this if any work has been done on the cooling system recently) and/or a faulty radiator. Serious problems like a faulty head gasket could cause this also. Unlikely in a 2004 unless the engine has ever seriously overheated. The first thing to do is make sure the coolant level is up to spec. You have to check this at the radiator, not just the plastic filler bottle. Also, if the guage moves into the red zone, the first thing to try is to turn on your heater full blast and the heater fan to max. This will usually offer some engine cooling. Roll down the window if you have to, it may get hot in the passenger compartment.
If it responds immediately to the headlights then I think it’s a poor ground connection.
Check the straps from the engine to the body of the car and any ground wires in the dashboard harnesses.