Hello, welcome to just answer
Here is what each code means
Code P0174 = Engine started, engine running at cruise speed for 3 to 4 minutes, and the PCM detected the Bank 2 Adaptive Fuel Control System reached its rich correction limit (a lean A/F condition).
Code P0171 = Engine started, engine running at cruise speed for 3 to 4 minutes, and the PCM detected the Bank 1 Adaptive Fuel Control System reached its rich correction limit (a lean A/F condition).
Here is a list of possible causes to set these and cause the symptoms you are havingAir leaks after the MAF sensor, or leaks in the PCV system Exhaust leaks before or near where the HO2S is mounted Fuel injector(s) restricted or not supplying enough fuel Fuel pump not supplying enough fuel during high fuel demand conditions Leaking EGR gasket, or leaking EGR valve diaphragm MAF sensor dirty (causes PCM to underestimate airflow) Vehicle running out of fuel or engine oil dip stick not seated
Carefully inspect the following areas for potential air leaks:
Hoses connecting to MAF
Hoses connecting to throttle body
Intake manifold gasket leaks
Vacuum lines disconnected
Improperly seated dip stick and tube
Exhaust leaks at flanges and gaskets
If any problems are found and you repair them, then clear codes and unhook negative battery cable for approximately 2 minutes. Reconnect negative battery cable and start vehicle to let computer relearn idle.
The reason it is okay for about 20 minutes after hooking up battery is because vehicle is running in open loop and does not care what the oxygen sensors are saying. It delivers a predetermined amount of fuel to engine until operating temperature comes up. Once up to operating temperature it goes to closed loop and now you have problems because it takes inputs from all sensors to make fuel adjustments and with a bad vacuum leak persay it will cause the problem you are having and cause those codes to set.