Common G-Code Mistakes Beginners Make
Most G-code mistakes fall into the same patterns. Learn to recognize these patterns and you will avoid 90 percent of the errors that cause crashed tools and scrapped parts. This guide covers the most common mistakes, shows you exactly what they look like in code, and gives you the fix for each one.
1. Missing Safety Block
The safety block is the first few lines of a program that explicitly set the machine modes. Without it, the program relies on whatever modes were left active by the previous program.
; Wrong — no safety block
M06 T1
M03 S3000
G00 X0 Y0 Z5
; If the previous program left G91 active,
; this "X0 Y0" goes to a completely different position
Fix: Start every program with a safety block:
G90 G94 G17 G54 ; Absolute, feed/min, XY plane, offset 1
G21 ; Metric mode
2. Cutting with G00
G00 moves at maximum machine speed. Using G00 while the tool contacts material causes the tool to plunge at full speed.
; Wrong — G00 while cutting
G00 Z-2 F100
; Correct — use G01 for cutting moves
G01 Z-2 F100
3. Forgetting G90
If a program ends with G91 active and the next program does not include G90, all coordinates are interpreted incrementally.
Fix: Always include G90 in your safety block. Always end subprograms with G90 before returning.
4. Activating Cutter Compensation Without a Feed Move
G41 and G42 require a G01 feed move on the same line to calculate offset direction.
; Wrong — alarm
G41 G00 X50
; Correct
G41 G01 X50 F200
5. Wrong Arc Direction (G02 vs G03)
Using G02 when you should use G03 causes the tool to cut into the workpiece instead of away from it. Viewing from positive Z, G02 is clockwise and G03 is counterclockwise.
6. Forgetting G80 to Cancel Canned Cycles
Canned cycles (G81, G83) are modal and stay active until cancelled with G80. Without G80, subsequent G01 moves may behave unexpectedly.
G81 R2 Z-10 F150
X50 Y50 ; Still drilling
G01 X100 ; Still in drilling mode
G80 ; Cancel cycle
7. Wrong Feed Rate for Plunging
Plunging needs a slower feed rate than horizontal cutting. Using the same rate for both breaks tools.
; Wrong — same feed for plunge and cut
G01 Z-2 F300
G01 X50 F300
; Correct — slower plunge, faster cut
G01 Z-2 F100
G01 X50 F300
8. Missing M30 at Program End
Without M30, the program may stop on the last line without rewinding. Always end every program with M30.
Prevention Checklist
☐ Safety block present (G90 G94 G17 G54)?
☐ G00 only used above the workpiece?
☐ G91 cancelled before subprogram end?
☐ Canned cycles cancelled with G80?
☐ Feed rates appropriate for operation?
☐ G41/G42 activated with G01 move?
☐ Program ends with M30?
What’s Next?
Detailed Mistake Analysis
1. Missing Safety Block — In-Depth
The safety block is the most important line in any CNC program because it creates a known starting state. Without it, the machine uses whatever modes were left by the previous program. If the previous program ended with G91 (incremental mode) active, your G00 X0 Y0 move goes to a different position than intended.
A complete safety block includes:
G90 ; Absolute positioning
G94 ; Feed per minute
G17 ; XY plane selection
G54 ; Work offset 1
G21 ; Metric mode (or G20 for inches)
M05 ; Ensure spindle is off
M09 ; Ensure coolant is off
This seven-line safety block takes no time to write and prevents the most costly CNC crashes.
2. Cutting with G00 — In-Depth
G00 does not respect the programmed feed rate. It moves each axis at its maximum possible speed. The tool path during G00 is also not necessarily a straight line — each axis moves independently. This makes G00 dangerous for any move where the tool is in or near the material.
; This G00 Z-2 move goes down at maximum speed
; regardless of the F100 written after it
G00 Z-2 F100 ; F100 is ignored by G00!
The F-word only affects G01, G02, and G03 moves. G00 always moves at the machine maximum speed.
3. Forgetting G90 — In-Depth
This mistake is insidious because the program looks correct when you read it. Each coordinate value appears normal. But if G91 is active, every coordinate is interpreted as a distance from the current position rather than an absolute position.
The most common scenario: a subprogram uses G91 for relative moves and does not switch back to G90 before returning. The main program then runs with G91 still active, shifting every subsequent position.
Diagnostic test: If the machine moves to unexpected positions that seem to increase with each move, G91 is likely active. Add G90 at the top of the program and test again.
4. Cutter Compensation Activation — In-Depth
G41 and G42 require a linear feed move to calculate the offset direction. The controller needs to know which side of the programmed path the tool is on, which requires at least one G01 move to establish the direction.
; Proper cutter compensation activation sequence:
G40 ; Cancel any existing comp
G00 X0 Y0 Z5 ; Position near the start point
G41 D1 G01 X10 Y10 F200 ; Activate left comp with feed move
; The tool is now offset to the left of the programmed path
; ... cutting moves ...
G40 G00 Z5 ; Cancel comp before retracting
5. Arc Direction — In-Depth
Wrong arc direction is easy to miss in simulation because the toolpath may look similar but the tool enters the material from the wrong side.
; External corner radius — use G02 (clockwise)
G02 X50 Y50 R10 F200
; Internal corner radius — use G03 (counterclockwise)
G03 X50 Y50 R10 F200
When in doubt, simulate with the backplot feature of your CAM software or G-code editor. The direction is visible in the toolpath display.
6. Canned Cycle Cancellation — In-Depth
Canned cycles like G81 and G83 are modal in most controllers. After starting a canned cycle, every XY positioning move drills a hole until G80 cancels the cycle.
G81 R2 Z-10 F150 ; Start drill cycle
X25 Y25 ; Drill hole 1
X50 Y25 ; Drill hole 2
X50 Y50 ; Drill hole 3
G80 ; Cancel drill cycle
G00 Z5 ; Safe retract — now in normal G00 mode
Without G80, the G00 Z5 move would retract to the R plane, not to Z5, because the canned cycle is still active.
7. Feed Rate for Plunging — In-Depth
Plunging places the entire force of the cut on the tip of the tool. Horizontal cutting distributes the force across the cutting edges on the side of the tool. The same feed rate that works for horizontal cutting is too aggressive for plunging.
Use a separate G01 move with a reduced feed rate for plunging:
G01 Z-2 F100 ; Plunge at slow feed
G01 X100 F400 ; Cut at fast feed
8. Missing M30 — In-Depth
Some controllers behave differently when the program ends without M30. On Fanuc controllers, the program ends but does not rewind, requiring the operator to manually reset before running the next part. On other controllers, the program may run past the last line and execute garbage data.
Always end every program with M30 to ensure consistent behavior across different controllers.
Debugging Strategy
When a program does not run correctly, follow these steps:
- Check the safety block first — most problems originate here
- Check for mode changes (G90/G91, G00/G01) that were not returned
- Check canned cycles for missing G80
- Check feed rates for appropriate values
- Simulate the program in a G-code simulator
- Run in single-block mode for the first real test
Learning from Mistakes
Every CNC programmer makes these mistakes at some point. The key is to catch them in simulation before they cause damage. Use the prevention checklist before every prove-out and you will catch the most common errors before they reach the machine.
Real-World Crash Scenarios
Scenario 1: The Disappearing Zero
A programmer set up a vise with soft jaws, set G54 at the corner of the part, and started the program. The first tool cut correctly. The second tool moved to X-50 Y-50 and plunged into the vise.
Cause: The first tool subprogram used G91 for a pocketing operation and ended with M99 but did not include G90 before returning. The second tool position was interpreted incrementally from wherever the first tool finished, not from the G54 zero.
Fix: Always end every subprogram with G90 before M99.
Scenario 2: The 100mm Hole
An operator programmed G81 X50 Y50 Z-10 R2 F150 to drill a 10mm deep hole. The drill plunged 100mm through the part and into the table.
Cause: The operator had previously used G91 for a different program and did not include G90 in the safety block. The G81 cycle interpreted Z-10 as an incremental move from the current Z position, not an absolute depth.
Fix: Always include G90 in the safety block at the top of every program.
Scenario 3: Tool Change Disaster
A program called M06 T2 and the machine moved to the tool change position. But the spindle was still running at 8000 RPM. The tool holder released and the spinning tool fell onto the workpiece, damaging both.
Cause: The programmer did not include M05 before M06. The spindle was still rotating when the tool change occurred.
Fix: Always stop the spindle before changing tools: M05 followed by M06.
How CAM Software Generates G-Code
Most beginners use CAM software to generate G-code. While CAM handles the basic syntax correctly, it can still produce programs with logical errors:
- Missing post-processor configuration for your specific machine
- Tool numbers that do not match your physical tool setup
- Feeds and speeds based on default values that may not suit your material
- Toolpaths that plunge straight down instead of ramping
Understanding the common G-code mistakes in this guide helps you spot errors in CAM-generated programs before they reach the machine.
Building Good Programming Habits
Developing consistent habits prevents most G-code mistakes:
-
Use a template. Start every program from the same template that includes the safety block and end sequence.
-
Comment your code. Every mode change should have a comment explaining what changed and why.
-
Simulate before cutting. Run every new program in a G-code simulator before touching material.
-
Single-block first run. Run the first part in single-block mode, checking each move before confirming.
-
Keep a mistake log. Write down every mistake you make and the fix. Review it before starting new programs.
The Most Important Rule
If you remember only one thing from this guide: always include a safety block at the top of every program. G90 G94 G17 G54 takes one line to write and prevents the most common and most expensive G-code mistakes.
Mistake Prevention Through Process
The most effective way to prevent G-code mistakes is not to memorize every possible error but to develop a process that catches errors before they cause damage.
Pre-Run Checklist
Before running any program for the first time:
- Read through the entire program from start to finish
- Verify the safety block is present and correct
- Check all M06 commands have matching T-words
- Verify M03 and S-words are paired on or near the same line
- Check that each subprogram ends with G90 before M99
- Verify the last line of the program is M30
- Run the program in a simulator
The 30-Second Scan
After writing or editing a program, scan through it looking only for these patterns:
- G90 at the top — is it there?
- G91 anywhere — is it followed by G90?
- G81 through G89 anywhere — is there a G80 after?
- M06 — is there an M05 before it?
- M30 at the end — is it there?
This 30-second scan catches 90 percent of common G-code mistakes.
What to Do When a Mistake Happens
Even with the best prevention, mistakes happen. When a G-code error causes a crash:
- Hit the emergency stop immediately
- Assess the damage to the machine, tool, and workpiece
- Identify the line of code that caused the crash
- Determine what was wrong with that line
- Fix the error in the program
- Verify the fix in simulation
- Run again with extra caution
Every mistake is a learning opportunity. The best CNC programmers are not the ones who never make mistakes — they are the ones who learn from every mistake and improve their process to prevent it from happening again.

G-Code Explained: How CNC Programming WorksJune 25, 2026 · Tutorials
G-Code for Beginners: Learn to Write Your First CNC ProgramJune 25, 2026 · Tutorials
G00 and G01: Rapid Traverse and Linear InterpolationJune 25, 2026 · Tutorials
G90 vs G91: Absolute vs Incremental Positioning in CNCJune 25, 2026 · Tutorials