P0031 and P0051 Codes – Check Engine Light, VSC TRAC, VSC OFF Light

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 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 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.

Entire circuit wiring diagram for a 2003 Toyota 4Runner available here as a zip file.

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 if you don’t have one yet: Multimeter Search Results on

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.

Scott enjoys fixing and improving cars, motorcycles, and his home in his spare time. He does his best to transcribe his journey as he navigates across unknown territory, finds himself in peculiar predicaments, and figures out how things work in the process.

Leave a Reply

7 Comment threads
23 Thread replies
Most reacted comment
Hottest comment thread
9 Comment authors
Scott LamCainPer Larseneduardo E floresDesmond Recent comment authors

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

newest oldest most voted
Notify of

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.



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.



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.

eduardo E flores
eduardo E flores

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

Per Larsen
Per Larsen

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


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

Copy link
Powered by Social Snap