---
title: "G28 Return to Home Position in G-Code, Explained"
description: "G28 sends the machine back to its reference (home) position, through an intermediate point you specify. Here is how it works and how to use it safely."
url: https://gcodepractice.com/journal/g28-return-to-home-position-explained/
canonical: https://gcodepractice.com/journal/g28-return-to-home-position-explained/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-04
updated: 2026-06-04
category: "Code reference"
tags: ["g-code", "g28", "home", "reference-return", "beginner"]
lang: en
---

# G28 Return to Home Position in G-Code, Explained

> **TL;DR** G28 returns an axis to the machine reference (home) position. It moves first to an intermediate point you specify, then from there to home. The intermediate point is read in the active G90 or G91 mode, so the safe habit is G91 G28 Z0 to lift straight to home in Z before a tool change. Always reset to G90 afterward.

`G28` is the code that sends the machine back to its **reference position**, the home point each axis finds when it homes. It sounds simple, but `G28` does not go straight home: it travels through an intermediate point first, and that detail is what trips beginners up.

## What G28 actually does

When the control reads `G28`, it moves in two stages:

1. Rapid to an **intermediate point** that you specify in the same block.
2. Continue from that point to the **machine reference** (home) position.

So `G28 X0 Y0` does not mean go to X0 Y0. It means rapid to the intermediate point X0 Y0, then carry on to home. The intermediate point is read in whatever positioning mode is active, which is why the [G90 vs G91](/journal/g90-vs-g91-crash-prevention/) setting matters so much here. The behavior is documented in the [LinuxCNC G-code reference](https://linuxcnc.org/docs/html/gcode/g-code.html) and the standard [reference-return guides](https://www.helmancnc.com/g28-cnc-reference-point-return-g-code/).

## The intermediate point is the catch

Because the intermediate point obeys the active mode, the same `G28` line behaves differently depending on what came before it:

| Block | Active mode | What happens |
| --- | --- | --- |
| `G90 G28 Z0` | Absolute | Goes to Z0 in work coordinates, then home (can plunge if Z0 is low) |
| `G91 G28 Z0` | Incremental | No move from current Z, then straight up to home (safe) |
| `G28 X0 Y0` | Absolute | Through work X0 Y0, then home (can swing across the part) |

The absolute version is risky: if your part zero sits low, `G90 G28 Z0` drives the tool down to Z0 before going home. That is why the field-standard habit is the incremental form.

## The safe pattern: G91 G28 Z0

The reliable way to clear the tool is to lift Z to home first, in incremental mode:

```
G91 G28 Z0   (lift straight to home in Z, no side move)
G28 X0 Y0    (then send X and Y home)
G90          (reset to absolute, always)
```

In `G91`, the `Z0` means zero distance from where the tool is now, so there is no intermediate detour. The axis simply rises to the reference point. This is the move you almost always want before an [M06 tool change](/journal/m06-tool-change-explained/) so the tool is clear of the part and fixture. The one rule you cannot skip: **reset to G90 afterward**, because leaving `G91` active will throw off every coordinate that follows.

## Where you see G28

`G28` shows up in two predictable places, which is why it belongs on any list of [common G-codes for CNC beginners](/journal/common-g-codes-for-cnc-beginners/) and is worth recognizing when you [read a CNC program](/journal/how-to-read-a-cnc-program-for-beginners/):

| Place | Why |
| --- | --- |
| Before a tool change | Get the spindle clear and at home for the change |
| End of program | Park the machine in a safe, known position for unloading |

A related code, `G30`, returns to a secondary reference point instead of home, useful when a machine has a dedicated tool-change or load position. The [G-code conventions](https://en.wikipedia.org/wiki/G-code) treat both as reference returns that share the intermediate-point behavior.

## Common mistakes with G28

Three errors cause most `G28` surprises. First, leaving `G91` active after the return, so the next absolute move lands in the wrong place; always follow with `G90`. Second, using the absolute form with a low part zero, which can plunge to the intermediate point before going home. Third, calling `G28` with cutter compensation still on: cancel it with `G40` first, because compensation through a reference return is undefined on many controls. None of these is hard to avoid once you know the move happens in two stages, not one.

For the full crash-postmortem version of what happens when the intermediate point is misread in G90 on a lathe, see [why the Z axis dives toward the chuck on G28](/journal/why-did-my-z-axis-dive-into-the-chuck-on-g28/).

## Bottom line

`G28` returns an axis to the machine home, but it travels through an intermediate point first, read in the active mode. Use `G91 G28 Z0` to lift straight to home in Z safely, then reset to `G90`. Avoid the absolute form unless you know exactly where the intermediate point lands.

## Sources

- [LinuxCNC G-code reference (G28 home)](https://linuxcnc.org/docs/html/gcode/g-code.html)
- [HelmanCNC: G28 reference point return](https://www.helmancnc.com/g28-cnc-reference-point-return-g-code/)
- [Wikipedia: G-code](https://en.wikipedia.org/wiki/G-code)

## Frequently asked questions

### What does G28 do in CNC?
`G28` returns the named axes to the machine reference (home) position. It rapids to an intermediate point you specify, then continues to home. It is used to park the machine safely, often before a tool change or at the end of a program.

### Why is G28 usually written as G91 G28 Z0?
In incremental mode, `Z0` means no movement from the current position, so the axis lifts straight up to home in Z with no sideways detour. Reset to `G90` right after.

### What is the difference between G28 and G30?
`G28` returns to the primary machine reference (home). `G30` returns to a secondary reference point stored in the control, selected with a P number on machines that support several.

### What is the best way to memorize CNC codes like G28?
Drill them with active recall. A free app like G-Code Sprint quizzes `G28` and the rest of the everyday codes as quick timed questions and repeats whichever ones you miss.

*G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.*

---

Source: https://gcodepractice.com/journal/g28-return-to-home-position-explained/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
