When you make purchases through links on this site, The Track Ahead may earn an affiliate commission. Also, these posts are based off my own experiences. I am not responsible for any action you take as a result of reading this. Learn More


Flashing Engine Lights

On my 2003 Toyota 4Runner, I’ve been dealing with a Check Engine Light (codes P0031 & P0051 came up simultaneously), and the VSC TRAC and VSC OFF lights for the past year. I’ve normally been able to pull the engine codes and then fairly quickly diagnose and repair the problem. However, this has been a completely different story. Not only was I not able to specifically pinpoint the issue causing the engine codes, I also could not find much useful information online.

p0031 p0051 vsc engine light codes


The dreaded Engine Light & VSC TRAC / VSC OFF that you may be familiar with if you’ve owned a Toyota. It is typical for the VSC TRAC and VSC OFF lights to come on which essentially puts it in “limp mode” as a safeguard since the engine light is on.

I normally search t4r.org for help, as well as Google search the issue. Surprisingly, there were only a handful of cases in which both codes come on at the same time. The information that I did find online provided little to no value to me.

Some forums had people who have the two P0031 and P0051 codes, but they would also have other codes at the same time. There were also a few others, but it ended up as an argument between the person who started the thread saying that replacing their gas cap resolved the problem and the forum veteran who was indicating that it was just not possible for that to be the answer. Honestly, I side with the vet, as the gas cap really has no relation to the air fuel sensor system. I also tried reaching out via private message to people who have posted threads on forums about this issue to see if they ever resolved the problem, but I found no luck there.

Air Fuel Sensors?

The P0031 and P0051 codes lead to a potential issue with the air fuel sensors in the car. I checked the codes on obd-codes.com and found the following:

A P0031 DTC trouble code may be caused by one or more of the following:

  • A short or open in the heater circuit in the sensor
  • A failed O2 sensor heater
  • Wiring/connectors broken/frayed leading to sensor and/or relay
  • Failed PCM/ECM

A P0051 DTC trouble code may be caused by one or more of the following:

  • A short in the heater circuit in the sensor
  • A failed O2 sensor heater
  • Wiring/connectors broken/frayed leading to sensor and/or relay
  • Failed PCM/ECM

The I went to a shop that specializes in Toyota and had them diagnose the issue, but they decided that I should replace both air fuel sensors. I had them do that work and it did nothing. The two codes still showed up. Not wanting to pay them for additional time to diagnose and try to find the problem, I chose to take my car back. I would recommend before you start replacing parts (unless it is super cheap to do so), you should do proper testing of the components before you start shelling out money aimlessly.

denso 234-9047 air fuel sensor
Denso Air Fuel Sensor (Part #234-9047) used for both B1S1 (Bank 1 Sensor 1) & B2S1 (Bank 2 Sensor 1) air fuel sensors

If you end up getting either the P0031 or P0051 codes individually, then it is very likely due to the failure of one of your sensors. Since my codes came up both P0031 & P0051 simultaneously, it was likely due to something else that triggered the codes at the same time. If you don’t get them at the same time, and only have either P0031 code or the P0051 code individually, replacing the air fuel sensor will probably be the solution.

After many months later, I finally had more time, so I looked for a shop that specializes in electronics as I knew this was a more advanced electrical issue. Next, I brought it into another place that specializes in car electronics and air conditioning (Advanced Auto Electric and Air Conditioning in San Ramon, CA). I talked and met with Daniel who would agree to diagnose the issue. I felt confident about his abilities while talking to him when I dropped the car off and we had a good discussion about what the next steps should be.

He went through the diagnosis within a day and came back to me saying that he went through the testing procedure for these particular codes and it indicates the ECU should be replaced. He gave me a few options, and I decided to go with the option to buy a used ECU off eBay and to replace it myself (simple replacement). I purchased one, replaced it, reset the codes, and the two dreaded codes still came up. Luckily, I was able to return it to the seller on eBay.

p0031 p0051 ecu replacement
Old and new ECU

I spoke with Daniel over the phone about it and he felt bad saying that he really thought that would have been it. He did some research on his own accord to see if he could find anything out. He even offered to take a look at it again, which I agreed to since I was so desperate to get this thing fixed.

His initial troubleshooting followed a troubleshooting procedure, but this time around he decided to do his own testing of the circuity. He got back to me later that day saying that there were some continuity issues at one particular location. And the good news was that he was able to get the codes to disappear by jumping the 3 and 5 pins on the A/F Heater Relay.

Troubleshooting with Circuit Diagrams

Although it was disappointing to hear that it was not fixed, I was optimistic as I knew it was possible to get the codes to disappear finally (even if it was by jumping the relay contacts). It was at this time that I felt I really needed to look at the circuitry of the air-fuel sensor system. I also learned that some of the circuit diagrams that I was using were not fully correct. Although the diagrams indicated it was for the 1GR-FE engine (which is what I own), it did not match some of the others that I found that were specific to my 2003 Toyota 4Runner. In the end, I realize that there was a mistake made on those diagrams that I found online, and that I should stick to the circuit diagrams that specifically indicate my Year, Make, and Model.

I’d like to add that it is is imperative to have a good multimeter to troubleshoot the electrical circuits in your car. Here are some multimeters on Amazon.com if you don’t have one yet: Multimeter Search Results on Amazon.com

Looking at the actual circuit diagrams for a 2003 Toyota 4Runner, I saw the following diagram for the Air Fuel Sensor System:

air fuel sensor wiring diagram
air fuel sensor wiring diagram 2

As you can see, there are several parts to this system that make up the air fuel sensor system:

  • air fuel sensors (P0031:Bank 1 Sensor 1 & P0051:Bank 2 Sensor 1 in this case)
  • A/F heater relay
  • EFI relay
  • ECU
  • wiring connections amongst all these components and to ground

I already had the air fuel sensors replaced, so I knew those were good. I also replaced the ECU which did nothing, so I knew that the ECU was fine as well. This narrowed it down to either the relays or the wiring. The relays are the easiest of the two so I looked at those.

Fuse box diagram for a 4th Generation Toyota 4Runner

Not only did I check the A/F Heater Relay and the EFI Relay by swapping them with the DOME Relay, I ran 12V of battery power through terminals 1 and 2, which would activate the relay through terminals 3 and 5. By using various wires and clamps, I performed this test and was able to hear (and even feel) the relay activate and deactivate.

Alas, I was stuck with trying to troubleshoot all of the wiring (which was Daniel’s conclusion where the trouble was). I busted out my multimeter and began using the circuit wiring diagrams above to check continuity across all circuits. A pitfall I ran into was looking at circuit diagrams that were not fully correct even though it indicated it was for this particular vehicle. After much frustration with the wiring not making sense, I pulled the specific circuit wiring diagram (from the zip file I provided above) for the 2003 Toyota 4Runner.

Starting off with the circuit diagrams that I knew were completely correct, I was able to do a true continuity test across the wiring in the air fuel sensor system. Testing across all of the components, I discovered that there was no continuity between the ECU (at the MREL connection) to the EFI Relay and A/F Heater Relay. I pulled the specific position of parts diagram showing how the wiring comes from the ECU (on the passenger’s side cabin) running across the cabin, through the firewall, and into the engine compartment to the relays.

Identifying the Problem

I pulled trim pieces inside the cabin to get access to the wiring along the way, and checked continuity over-and-over again until I found the culprit. I discovered that the wiring that runs through the firewall (circled in red below) had a break in it. After fumbling around with the junction connector (J4) and wiring at that location, I was tugging on the wires that ran through the firewall when the wire came off in my hand. Basically there was damage to the wire inside of the firewall, which caused discontinuity in the wire between the ECU and the relays in the fuse box.


Position of parts diagram which helps me identify the exact locations of the wiring and any connectors along the way

p0031 p0051 broken wire

It’s a little hard to see, but this is the view from within the cabin looking at the firewall. The wire on the right is the white/green wire which was disconnected (it is actually broken at the top of the photo).

Making the Electrical Repairs

Since I had no access to within the firewall, and the wiring in the engine compartment was hidden within the loom that ran to the fuse box, I had to run new wiring through the firewall to underneath the fuse box. I ran a new larger gauge wire through the firewall by taking apart a metal clothes hanger, and guided the wire through with it. The new larger gauge wire is the black wire you see below.

p0031 p0051 spliced wire

The existing white/green wire was cut where junction connector J4 is, then soldered to the new wire.

p0031 p0051 firewall engine side

This view is from the engine compartment looking at the firewall. You can see that it would have been difficult to find the existing white/green wire within the taped wire loom, so I ran the new black wire that you above.

p0031 p0051 2003 4runner opened engine fuse box

The fuse box was a pain in the arse to take apart. There are 4 tabs that needed to be depressed while pulling the fuse box into two pieces. After it was removed, this is what it looks like.

p0031 p0051 engine fuse box wiring

The black wire that ran through the firewall is soldered to underneath the A/F Heater Relay connection #1 contact.

p0031 p0051 2003 toyota 4runner fuse box

Fuse box all put back together again.

p0031 p0051 fixed


I then cleared the codes, and no more Christmas lights going off on my instrument cluster.

If you have had a similar problem, feel free to reach out to me and I can try to help. I know how frustrating such an ordeal can be.

Author

Hi there! I'm Scott and I run The Track Ahead. My goal is to write helpful articles, tutorials, and reviews based on my personal experience with car maintenance and detailing. I've been wrenching on and detailing cars for 15+ years and now share my knowledge with others on this site to help them care for their vehicles.

45 Comments

  1. Holy cow dude, nice job on finding the source of the P0031/51 issue. I know it takes a long time to troubleshoot wiring problems and you did a great job.

    • Nice job- I’ve got the same on a 2007 rav4 p0031.51 I believe it is a problem similar to yours. sensors check out but not seeing the full 12 volts to them- checked out the a/f fuse grounds etc. looks ok. will be looking for a broken wire,

      • Not getting a full 12 volts is not always an issue. I did follow a troubleshooting procedure online for my 4Runner such as the following:

        http://4runnerclub.com/i/4r_files/fsm/ToyManuals-2007-4Runner/toyfsrm/07toyrm/07toypdf/07rmsour/4runnerr/0050014.pdf

        And when I tested the air/fuel sensors, I tested by checking resistance. I would try following a troubleshooting procedure similar to the one I linked above (try searching online for one), so that it can help you narrow down the problem area. Then, you can use something like this electrical wiring diagram (in color, which helps a lot) to visualize the entire electrical system that is potentially causing your codes within the problem area you’ve identified:

        http://mr2.bordeauxgroup.com/ (click on 2007 Toyota RAV4 Electrical Wiring Diagrams (EWD).pdf)

        I would print out all the diagrams you need, and start scratching the lines out one-by-one as you test for continuity/voltage to narrow down the problem even further. Consult with the connector location diagrams within that pdf as well. Good luck!

    • Hello Scott,

      I have the same issue with my 2008 Toyota 4-Runner V-6; however, the check engine light, VSC TRAC, VSC Light Off, P0031 and P0051 codes are read as soon as the rear window defrost is turned on. The lights will stay off and codes disappear after resetting and remain that way as long as the rear window defrost is not used. Do you have any ideas? I have been trying to diagnose this problem for months. Definitely not a sensor problem. Shops can’t find the problem

      • Now that is really strange. Yeah I’m pretty sure it’s not the sensor, but some sort of electrical issue when you press the rear window defrost switch. Have you tried tracing out the wiring from the rear defroster?

        I would look at the zip file I have on the post, which includes wiring diagrams. In that zip file, there is a folder called System Circuits. In there, you can try looking at the 061rwdmh.pdf which is the circuitry for the rear window defogger and mirror heater. You might have to see how that defogger switch possibly crosses the circuitry for the af heater sensors.

        I can take a look when I have time and let you know if I can come up with any ideas.

      • Does the rear defogger work? Have you done any work on the car that you think may have compromised any wiring?

  2. Scott;

    Great info. Can you please let me know the part# of Denso Sensor as Part #234-9047 that you listed is not for V8.

    My car is “2003 TOYOTA 4Runner V8”, The CODE is P0031, and lights on as your car.

    Thanks,
    Ming

    • I did a quick check with the Denso part numbers and the OEM Toyota part numbers and here is what I see:

      2003 Toyota 4Runner V6
      OEM 89467-60010 (Front Both Sides) — matches with Denso 234-9047
      OEM 89465-60220 (Rear Left) — matches with Denso 234-4084
      OEM 89465-60230 (Rear Right) — matches with Denso 234-4805

      2003 Toyota 4Runner V8 (you will want to confirm this information before buying)
      OEM 89465-60150 (Exhaust Manifold Both Sides) — matches with Denso 234-4138
      OEM 89465-60200 (Front Pipe) & OEM 89465-60250 (Catalytic Converter) — seems to match with Denso 234-4260/234-4261

      The configuration between the V6 & V8 appears to be different with the air fuel sensors being called that for the V6 and it being called oxygen sensors for the V8. Since I’m only familiar with the V6, I’m not exactly sure about the V8 but you can likely compare the OEM part number that you need with the related Denso part number. Hope that helps.

  3. Very informative post Scott, thanks for taking the time 🙂 I have a Toyota Mark X with both these codes – the thing is I’ve scoped the oxygen sensors and they’re getting a positive feed to the heaters which is getting switched by the ECU.

    • I just want to make sure, you’re talking about the air fuel sensors right? If you’re getting those two codes, you probably want to start with getting the wiring diagram specific to your Mark X and checking the connections and wiring as I did.

      • Yes, it’s the air fuel sensors. Both sensors have been replaced by a mechanical workshop a few days ago because of these two faults. I can’t find a wiring diagram but found a Toyota troubleshooting pdf for the engine. I connected the oscilloscope to them and the heater is getting an ignition on one side and is being switched to ground via pulses on the other side so must be connected to the ECU. Yesterday the workshop called again and mentioned that the customer has had the ECU “reflashed” a month ago so I’m wondering if they have messed up the ECU.

        • It’s possible a reflash could have messed something up. The issue could be related to the system rather than just the connections directly leading to the air fuel sensors. That’s why it’s imperative to have the exact wiring diagram for the vehicle (I would imagine it’s got to be out there somewhere for your specific vehicle) in order to trace out the system and rule out any other potential short/discontinuity issues. Good luck, sounds like an interesting one!

          • sorry, I forgot to get back to you – the mechanics had fitted two rear O2 sensors instead of front sensors – the resistance of rear sensor heaters is 11-16 ohms while front sensors are 3-4 ohms. The ECU didn’t like the 11 ohm resistance 🙂

          • Sometimes the issue is so simple isn’t it? Glad you guys figured it out!

          • The thing is it really throws you off when someone says the parts are brand new.

          • Well technically they were new… =)
            But you aren’t alone, I’ve read about this happening many other times on forums.

  4. eduardo E flores Reply

    same thing happend to my 07 rav4 AFTER i connected a kit for the trailer lights for towing…the headlights fuse burn out and i got the check engine light with codes p0031 p0051 ….i erase the codes but they come back in less than a minute…i remove the trailer light kit and still getting the same problem

    • I would inspect every part that you touched on the wiring to see where it may have been disconnected or damaged. When I got my code, it turned out to be a damaged/disconnected wire right where I had tried fishing a wire hanger through the firewall.

      It is a tedious process, but you’ll need to chase the wiring to make sure nothing was damaged. Good luck!

  5. Per Larsen Reply

    Hi Scott. Finally I found something that could help me.Great post btw.
    I have some problems like yours but the other way around. I have a FJC 2007 but as I can see from yours diagram we seem to have the same electrical system.
    My problem is that EFI relay and A/F heater relay activates randomly even when car sits still and after a few days it has drained my battery.
    Only way to make them go off is to cut power to the ECU.
    Then its all good for a while, sometimes one day, sometimes two or three days.
    I got the same fault lights as you but not always.

    So what I want to know is what triggers the MREL on the ECU to activate these relays?
    Tryed to talk with Toyota mecanics but they only says I should bring it in but I see money disappering if I do that.

    If you have any info for me how to go on with my troubleshooting it would be most helpful.
    Maybe bad A/F sensor triggers the MREL output?

    I should also tell you I got a supercharger upgrade from URD with an additional ECU for higher performance.
    I have been in contact with them but they said they never heard of this problem.

    My plan is to rule out any other troubles I may have so I am sure whats wrong before I get back to URD and claim any faults in their parts.

    I am Swedish so my english may have more to wish. Hope you understand.

    Have the best//Per

    • Thank you, I appreciate the kind words.

      I just want to note that it is very important to get the exact wiring diagram for your exact vehicle. Although our cars can be quite similar with the FJC and 4Runner, I’d recommend finding the specific wiring diagram for your car. This will rule out the possibility of following an incorrect wiring diagram (which can possibly drive you crazy).

      The ECU is the unit that would be triggering the relays, and since your ECU has been tuned/changed out for your supercharger, I’d recommend searching for other people with the same supercharger and if they have run into similar issues. I’d probably talk to URD to see if they have had any experiences with this. Did your problem happen right away after the ECU was changed out? If so, I’d look more closely at the new ECU as being the culprit.

      The main thing I’ve learned about my issues with these codes and eventually fixing them is that under normal vehicle operation (and no modifications), the engine codes will generally show you what is wrong and what needs to be fixed. Any time modifications are made (even if you’re working on the car with something other than general maintenance), you are increasing the chance of something going wrong. I’ve learned that when you get not-so-common engine codes (like the P0031/P0051 at the same time), it is likely caused directly or indirectly from the modification of something.

      Perhaps you could narrow down what is causing the issue by changing out the ECU with your original ECU, and see if you are still getting your battery drain. I hope this helps, and wish you lots of luck!

      • Per Larsen Reply

        Scott, thanks.
        I got the correct electrical diagram and I am an electrician so no problem reading them.

        What I really want to ask you if you have any ideas regarding what triggers the EFI and A/F heater relay. Is it only when ignition is on?
        Should they at any time get activated by the ECU when car is parked and locked? In that case why?

        I am just curios and want to find out if there is any other things that failing and wants to trigger the MREL output on the ECU.

        I now have connected the stock ECU only and will try it out for a week or so to see if my problems goes away.
        If it turns out that theres no problems using the original ECU I sure will get back to URD.

        Thanks again for your respons Scott, I will update when I know more. If you want me to.

        //Per

        • So I don’t really know the specifics of when the EFI and A/F heater relays are activated (key to off, ignition, on). However, an easy way to tell is to get access to the ECU and use a multimeter, plug your leads into the back of the MREL output and a ground, and check voltage with the key set to off, ignition, and on. Then you can tell if MREL is being activated in any of those cases. I’d probably do it with both the stock ECU and the upgraded ECU to see if there’s any difference.

          To me, doesn’t seem reasonable for the ECU to activate the EFI and A/F heater relays while the car is off.

          • Per Larsen

            Good thinking Scott, I will try that.
            Thanks.

  6. I got a toyota 4runner 2006 and i have a check engine the code is p0051 and after trying to reset it it comes back on in less then a minute

    • P0051 is the code for the Air Fuel Sensor Bank 2 Sensor 1. This sensor would be located after the exhaust manifold, but before the catalytic converter. This location depends on if you have a V6 or V8. What do you have?

  7. Very good post!! I have a 2007 Lexus IS 350 with the same codes P0031 and P0051 both Confirmed and Pending (1 of each one for each code). Weird because this has been on now for over 500 miles yet the Pending ones have not disdapeared and confirmed themselves.

    I like you do not want to go changing out parts and see it very odd both O2 sensors going out at the same time which leads me to believe it is an electrical/fuse problem…but WHERE???

    • Thanks! Hopefully you have some access to some electrical wiring diagrams for the IS350. I luckily had a copy for the 4Runner which allowed me to track it down, but it took so long to do. I wish you the best of luck; just get those electrical wiring diagrams, that’s definitely the first step to getting you there.

  8. I have a 08 Toyota mark x and got a code p0051 Oxygen a/f sensor heeater control circuit low (bank 2 sensor 1) how can i go abt fixing the issue?

    • You will need to look for the bank 2 sensor 1 oxygen/air-fuel sensor and check if that is the problem. There are ways to test those sensors, but replacing MIGHT fix it. Good luck.

  9. Jesus Vilchez Reply

    hello friend, I was going to install some external lights to my 4runner 2005 V6, to test take the power from a connector in the fuse called: Short Pin, from that moment the service light turned on with the codes P0031 and P0051, I already changed the sensors, the relays and nothing goes off, I don’t know what to check anymore, any suggestions, thanks!

    • Hi there, is the fuse you’re talking about from the fuse box under the hood or in the engine compartment?

      • Jesus Vilchez Reply

        Thank you!! yes, this fuse is in the compartment that is in the engine, it is the one that says SHORT PIN, just connect some lights to test and from that moment the Check engine light came on with these codes P0031 and P0051, I already changed the sensors , the relays and nothing keeps turning on the service light

  10. Hi Scott,

    great article! It helped me a lot to dig into the source of problems I face currently with my 2003 4runner.
    It is very similar to what Per Larsen described. Only that the EFI and R/F Heater relays immediately turn on as long as the battery is connected to the system. So no key is put in. I measured 2.5 Ampere drain at all time which means the battery is dead over night.

    The MREL pin on the two relays is on 12 volts always so that triggers them immediately. So this could be something strange in the fuse box or the ECU is gone haywire. I don’t know how to disable the ICU though to confirm this. Do you have any idea?

    • Hi Richard,

      Thanks. That is certainly odd, just right off the bat it sounds like a short issue somewhere. If you’re trying to diagnose the fuse box or the ECU, I’d say start with swapping out the ECU first (I believe it was easy to swap out without any major issues… sorry it’s been a while since I’ve had this car). At least that can help narrow down things before you start going deep into the wiring. Sorry I couldn’t be of more help.

  11. Thank you for your input. I disconnected the ECU from all connections and the current stopped. I opened the ECU and one of the transistors looks damaged and it also shows much smaller inner resistors compared to other elements on the ECU board that look like the same SMD element. I ordered a “new” used ECU now and hope it resolves the issue. Thank you!

  12. Hey Scott, great article and I commend you for your persistence and diligence to finding the source of your problem. Really appreciate you sharing too, very helpful. Wanted to get your thoughts on my 2004 4runner situation where I now have the P0031 and P0051 codes simultaneously. Here is the scenario…I recently had a local mechanic replace the bank 1 and bank 2 CATs due to P0420 and P0430 codes present. A week later the codes came back so I took it back and he discovered his welder put the new CATs on the rear instead of the front! A WTF moment for all no doubt! He then got a different welder to move them to the front and the P0420 and P0430 codes went away and now the P0031 and P0051 are present! I should mention that the vsc trac and vsc off lights are both on and had been prior to any of the previous work with the CATs. Not sure those are related to anything since they were pre-existing. Anyway, I know it sure seems like a mess but doesn’t seem to me like any wires woukd have been compromised. Mechanic is going to do some voltage and resistance checks tomorrow to check sensors. Anything come to your mind based on the situation described?

    • Thanks Aaron. That sounds like one heck of an ordeal… hopefully things have gotten more sorted out since you wrote this. My apologies in advance, but my memory is a bit cloudy since I haven’t dealt with this issue for some time now. It’s possible that they moved the new cats from the rear to the front, which took care of your P0420/P0430 codes as expected. But your air fuel heater sensors may have gotten affected somehow during all of this work. You may want to try having those sensors removed, cleaned up, and reinstalled to see if the codes still come up. If it does still come up, you may want to try replacing them to see if it fixes it. It’s possible it could be something else as well, but this may be worth a try.

  13. Just came across this post and I think you did a great job with it and with your truck. I am currently looking at a 2005 Tacoma with a v6 in it and was surprised to see it had 10 codes total, 5 stored and the same 5 pending. It has p0102, p0031, p0037, p0051 and p0057. I can see one sensor going bad at a time. I have a hard time with all 4 being bad. Thoughts on it?

    • Thanks, as I mentioned in the post it took a really long time to troubleshoot. Honestly, I wouldn’t be able to tell you… for example let’s say someone decided to run Seafoam through their car which resulted in carbon deposits gunking up all of the oxygen sensors and air/fuel sensors. It’s possible it could throw all of these codes, but you also have a MAF sensor code there too. It’s really hard to say without actually taking a look at the vehicle. Sorry I couldn’t be of more help, but hopefully you are able to get a chance to take a closer look at it.

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.