Browser GET Request to the Root Path

A beginner-friendly walkthrough of opening your running Axum server in a web browser, understanding the GET request to the root path, and confirming your Hello World response appears correctly.

A web browser is one of the most direct ways to test a running web server. Once cargo run has started your Axum application and the terminal shows no compile errors, the next natural step is to open a browser and visit the server's address. This page covers exactly that: what happens when you type http://127.0.0.1:3000 into your browser's address bar, why the browser sends a specific kind of request called a GET request, how the browser and your Axum server communicate in that moment, and how to confirm the response you see is correct.

What a Browser Does When You Visit a Web Address

Every time you open a website - a news page, a search engine, a documentation site - your browser performs a series of steps that you never see. The browser takes the address you typed, figures out which computer on the internet (or on your own machine) should receive the request, connects to that computer, and asks for a specific resource.

When you type http://127.0.0.1:3000 into the address bar and press Enter, you are telling the browser three separate things:

  • http is the protocol. A protocol is a shared set of rules for how two programs talk to each other. HTTP (Hypertext Transfer Protocol) is the ruleset used for transferring web pages, text, images, and other content between a server and a client. The browser is the client, and your Axum program is the server.
  • 127.0.0.1 is the IP address. An IP address is a numeric identifier for a device on a network. 127.0.0.1 is a special address called the loopback address - it always points to your own computer. Typing it means "connect to the machine I am currently using."
  • 3000 is the port. A port is a numbered communication channel on a computer. Many different server programs can run on the same machine at the same time, and the port number tells the operating system which program should receive the incoming connection. Your Axum server is listening on port 3000, so the connection goes there.

The browser combines these pieces, connects to your own machine on port 3000, and sends an HTTP request asking for the root path. The root path is represented by a single forward slash (/) and means "the top-level resource of this website."

The GET Request That Your Browser Sends

The specific kind of HTTP request the browser sends when you type an address and press Enter is called a GET request. HTTP defines several request methods - also called verbs - and each one communicates a different intention to the server. GET is the method for "please send me the content at this path." It is the default action a browser takes when you visit a URL.

Your Axum server was set up with a route that matches exactly this request. Here is the src/main.rs file the server is running:

use axum::{
    routing::get,
    Router,
};
#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(|| async { "Hello, World!" }));
    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    axum::serve(listener, app).await.unwrap();
}

The line .route("/", get(|| async { "Hello, World!" })) is the part that responds to the browser's GET request. It says: when a GET request arrives for the path /, run this handler function and send back whatever it returns. The handler in this case is a closure - a small anonymous function - that returns the string "Hello, World!".

When you open the browser and visit http://127.0.0.1:3000, the browser sends this request, Axum receives it, matches it to the / route, executes the handler, and builds an HTTP response containing the string. The browser then displays that string on the page.

Opening the Browser for the First Time

Before opening the browser, make sure the terminal where you ran cargo run still shows the server running. You should see no further output after cargo run completes - the server is silently waiting for incoming connections. The terminal prompt will not return, and that is expected. The program is actively listening.

Now open any browser - Chrome, Firefox, Edge, Safari, or any other - and type this exact address into the address bar:

http://127.0.0.1:3000

Press Enter. After a very short moment, the browser will display the plain text response:

Hello, World!

The page will have no styling, no images, no structure - just that one line of text. This is exactly what you should see. The browser has no information about fonts or colors because your Axum handler returned only a raw string. Axum treated that string as plain text and sent it in the response body with a content type of text/plain. The browser displays plain text content without any formatting.

Everything Is Working Correctly:

If you see "Hello, World!" on the page, the full request flow is functioning. Cargo compiled the code, the server started, the TCP listener is accepting connections, the router matched the request, the handler executed, and the response traveled back to the browser. This is the complete end-to-end path of a working Axum application.

Using localhost Instead of 127.0.0.1

Many tutorials and examples use the word localhost instead of the numeric address 127.0.0.1. Both refer to the same thing: your own computer. The difference is in how they are resolved.

localhost is a hostname, a human-friendly name that the operating system translates into an IP address. On virtually every system, localhost resolves to 127.0.0.1. You can verify this by typing either address into your browser - both will reach the same Axum server.

Here are both valid addresses:

http://127.0.0.1:3000
http://localhost:3000

Both produce identical behavior. Choose whichever you find easier to remember. Many developers use localhost in documentation because it reads more naturally, while 127.0.0.1 is more explicit about the networking details.

One Small Difference on Some Systems:

On most machines, localhost resolves to 127.0.0.1 automatically. On a few systems with custom configuration, localhost could resolve to the IPv6 loopback address ::1 instead. If one address works and the other does not, try the numeric form http://127.0.0.1:3000 - it removes any hostname translation from the equation.

What You See in the Address Bar After Loading

After the page loads, the address bar may still show exactly what you typed: http://127.0.0.1:3000. The trailing slash is important. The root path in HTTP is always /, and the address http://127.0.0.1:3000 is treated by the browser as equivalent to http://127.0.0.1:3000/. The browser adds the slash silently if it is not visible.

Try typing both forms and observe the result:

http://127.0.0.1:3000
http://127.0.0.1:3000/

Both send a GET request to the root path and both will display Hello, World!. Axum's router does not distinguish between the two forms because the route definition / matches the request path regardless of how the browser displayed the URL.

Looking at the Request in Browser Developer Tools

The browser's visible page only shows the response body - the text Hello, World!. But under the surface, the browser and server exchanged much more information: request headers, a status line, response headers, and a response body. You can inspect all of this using the developer tools built into every major browser.

Here is how to open them:

1

Step 1: Open Developer Tools

With the Axum page open in your browser, press F12 on Windows or Linux, or Cmd+Option+I on macOS. The developer tools panel will open at the bottom or side of the browser window.

2

Step 2: Switch to the Network Tab

In the developer tools panel, find the tab labeled "Network" and click it. This tab records all network requests the browser makes after you open it. It may already contain the request for the current page.

3

Step 3: Reload the Page

Press F5 or the browser's reload button while the Network tab is open. Reloading forces the browser to send a fresh GET request to the server, and the Network tab will capture it.

4

Step 4: Find the Request Named `127.0.0.1` or `/`

In the list of captured requests, look for an entry with a name like 127.0.0.1 or /. Click on it to open the detailed view. This is the GET request your browser sent to the Axum server.

In the detailed view, you will see a status code of 200 OK. The number 200 is the standard HTTP status code that means "the request succeeded." You will also see the request method listed as GET, the remote address showing 127.0.0.1:3000, and a response body containing Hello, World!.

Status Codes in One Sentence:

Every HTTP response includes a three-digit status code. A code starting with 2 indicates success, 4 indicates a client-side problem, and 5 indicates a server-side problem. 200 OK is the standard success response for a GET request.

What Happens If the Browser Cannot Connect

A common experience when learning is typing the address and seeing an error page instead of Hello, World!. Different browsers display different messages, but they all communicate one of two underlying problems: the server is not running, or the address is wrong.

The most common error page in Chrome says "This site can't be reached" and includes the text "127.0.0.1 refused to connect." Firefox shows "Unable to connect." Both mean the same thing: the browser attempted to open a connection to port 3000 on your machine, but nothing was listening there.

The Server Is Not Running:

If you see a connection-refused error, check the terminal where you ran cargo run. If the program stopped - for example, because you pressed Ctrl-C or closed the terminal - the server is no longer listening. Run cargo run again from inside the my-axum-app directory, wait for it to compile and start, and then refresh the browser tab.

Another possible error appears when the address uses the wrong scheme. If you type https://127.0.0.1:3000 by mistake, the browser attempts a secure HTTPS connection, but your Axum server is speaking plain HTTP. This produces an error like "SSL_ERROR_RX_RECORD_TOO_LONG" in Firefox or a similar message in Chrome. The fix is to change https back to http in the address bar.

Checking the Terminal While the Browser Makes Requests

Your terminal will continue to show only the output from cargo run - which, for this simple example, is nothing after the initial compilation messages. Axum itself does not print anything when a request arrives unless you add logging middleware or a print statement inside the handler.

To prove that the handler is actually executing each time the browser sends a GET request, you can add a println! line to the handler and restart the server. Here is the modified src/main.rs with a print statement:

use axum::{
    routing::get,
    Router,
};
#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(|| async {
            println!("Handled a GET request for /");
            "Hello, World!"
        }));
    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    axum::serve(listener, app).await.unwrap();
}

After making this change, stop the running server with Ctrl-C, run cargo run again, and refresh the browser. Each refresh prints the message in the terminal. This is a useful beginner technique: adding visible output confirms that a specific part of your code ran. The same technique works later when you need to trace the flow of more complex handlers.

You Must Restart the Server to See Code Changes:

Rust compiles the code before running it. Changing src/main.rs while the server is running does not update the running program. Stop the server with Ctrl-C, run cargo run again, and the new code will be compiled and executed. This manual restart loop is part of the normal development workflow in Rust.

Refreshing the Page Sends the Same GET Request Again

After the page has loaded, pressing F5 or the browser's reload button performs the same action as typing the address again: the browser sends a fresh GET request for the current path, receives the response, and re-renders the page.

For a static response like Hello, World!, each refresh produces an identical page. There is no visible difference because the handler returns the same string every time. But the request and response cycle happens anew on every refresh. The browser does not cache a local copy and skip the network in this case because the response did not include caching headers that tell the browser to do so.

This behavior matters as you begin to build handlers that change over time. If a handler returns different content on each request - for example, a counter that increments or data fetched from a database - refreshing the page will reveal that new content. The GET request and the handler execution are tightly linked: one request from the browser always triggers one invocation of the matching handler.

Adding a Second Route and Testing It in the Browser

Once the root path works, a natural experiment is to add another route and verify it in the browser. This builds confidence in how paths and handlers connect.

Modify src/main.rs to include a second route:

use axum::{
    routing::get,
    Router,
};
#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(|| async { "Hello, World!" }))
        .route("/about", get(|| async { "This is the about page." }));
    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    axum::serve(listener, app).await.unwrap();
}

Stop the server, run cargo run again, and test both addresses:

http://127.0.0.1:3000
http://127.0.0.1:3000/about

The first shows Hello, World! and the second shows This is the about page.. The browser sends a GET request for whichever path you place after the port number. Axum's router compares that path to its route definitions and runs the matching handler. If no handler matches, Axum returns a 404 status code with an empty body, and the browser shows a blank page.

What a 404 Looks Like in the Browser

Try visiting a path that has no matching route:

http://127.0.0.1:3000/does-not-exist

Axum answers with status code 404 and an empty body - the default fallback sends no text at all. The browser receives that empty 404 response and shows a blank page. There is no "404 Not Found" page supplied by Axum here; if you want visitors to see a friendly message, you have to build that response yourself with a fallback handler.

This is worth experiencing intentionally because it teaches the relationship between routes and browser requests. The browser does not care whether the path exists; it sends the GET request regardless. The server decides whether the path is valid and returns either a success response or a 404 response.

The Complete Request-Response Timeline

From the moment you press Enter in the browser to the moment you see Hello, World! on the screen, a precise sequence of events occurs. Understanding this timeline helps demystify what the browser and server are doing:

Browser (client)                        Axum (server)
      |                                      |
      |  1. Connect to 127.0.0.1:3000       |
      | ----------------------------------> |
      |                                      |
      |  2. Send GET / HTTP/1.1             |
      |     with request headers            |
      | ----------------------------------> |
      |                                      |
      |                                      |  3. Router matches GET /
      |                                      |  4. Handler executes
      |                                      |  5. Build HTTP 200 response
      |                                      |
      |  6. Send 200 OK with                |
      |     "Hello, World!" body            |
      | <---------------------------------- |
      |                                      |
      |  7. Browser renders body            |
      |                                      |

The connection in step 1 is a TCP connection - a reliable channel between the browser and the server. The request in step 2 contains the method (GET), the path (/), the HTTP version, and a set of headers with metadata. The router in step 3 compares the method and path to its route table. The handler in step 4 is the closure you defined. The response in step 6 contains the status code, response headers, and the body string. The browser renders that body in step 7.

This entire cycle happens in milliseconds for a simple local server. The browser hides all the intermediate steps and shows only the final result.

Testing with Multiple Browser Tabs

Opening the same address in multiple browser tabs provides a simple way to observe that the server handles separate requests independently. Each tab maintains its own connection to the server and sends its own GET request. The handler runs once for each tab that loads the page.

This matters because web servers are designed to handle many simultaneous clients. A single browser with many tabs is a small version of many different users hitting the same server. Your Axum server is already capable of this concurrency because axum::serve runs on the Tokio async runtime, which can process multiple connections concurrently. You do not need to change any code for this to work.

Beginners frequently encounter a small set of problems when testing an Axum server in the browser. These are all easily diagnosed if you know what to look for.

The most common mistake is typing the address incorrectly. The exact string matters. http://127.0.0.1:3000 has four parts, and each one must be correct. Modern browsers usually recognise an address like 127.0.0.1:3000 even without the http:// prefix and navigate straight to it, but typing the full address is the safest habit - a typo in the IP address or port still sends the request to the wrong destination.

The Leading Slash in the Path:

When typing the root address, the path is just /. Writing http://127.0.0.1:3000/ is correct. Writing a path with a space or extra characters, like / or /home, sends a request for a path that may not exist. The root path is exactly / and nothing else.

Another mistake is forgetting that the server must be running. The browser cannot start your Axum program for you. If the terminal shows a prompt instead of a running process, the server is not active. Run cargo run first, and only then open the browser.

A third mistake is changing the code but not restarting the server. After editing src/main.rs, the old binary is still running. Stop it, recompile, and run again before testing.

Verifying the Response Headers in Developer Tools

The response body Hello, World! is only one part of what the browser receives. The response also includes headers that describe the body and the server. In the Network tab of developer tools, click on the request and then find the "Response Headers" section. You will see entries similar to these:

HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
content-length: 13
date: ...

The content-type header tells the browser how to interpret the response body. text/plain means the body is plain text with no formatting. The charset=utf-8 part declares the character encoding, which determines how bytes are converted into readable characters. The content-length header states the size of the body in bytes. The string Hello, World! is 13 bytes long - 13 characters, each one byte in UTF-8.

The browser uses these headers to decide how to render the response. If the content type were text/html, the browser would interpret the body as HTML markup and apply formatting accordingly. Because the content type is text/plain, the browser displays the raw string as unformatted text.

Using Different Browsers to Confirm Consistent Behavior

The same Axum server responds identically regardless of which browser sends the request. You can verify this by opening http://127.0.0.1:3000 in Chrome, Firefox, Edge, and Safari simultaneously. All four will display Hello, World!.

The server does not know or care which browser is making the request. It receives the same HTTP GET request from each one and produces the same HTTP response. The browsers might render the page with slightly different default fonts or margins, but the text content is identical.

This browser-agnostic behavior is a core property of HTTP: it defines a standard that all clients and servers agree on. Your Axum server speaks standard HTTP, so any standard HTTP client - browser, command-line tool, or programmatic client - can communicate with it.

What to Observe Before Moving On

By this point, you should have observed all of the following:

  • The browser connects to your local Axum server when you type http://127.0.0.1:3000
  • The browser sends a GET request for the root path /
  • The Axum router matches that request to the handler registered at /
  • The handler executes and returns Hello, World!
  • The browser displays that string as an unformatted plain text page
  • The developer tools show a status code of 200 OK
  • Refreshing the page repeats the entire request-response cycle
  • Visiting an unregistered path produces a 404 response with an empty body, and the browser shows a blank page

Each of these observations confirms a separate piece of the full system. Together they demonstrate that your Axum application is functioning correctly as an HTTP server.

You Have Verified the Server End-to-End:

The ability to see "Hello, World!" in the browser means the code compiled, the server started, the TCP listener is accepting connections, the router matched a real request, the handler produced a response, and the response traveled back across the network. This is the complete verification milestone for a minimal Axum server.

Summary

Opening the server in a browser turns the pieces you built into one visible result, and it also gives you a way to read the server's answers: what you see on the page is the response body, what the address bar holds is the request path, and what the Network tab shows is the status line and headers around that body. When something goes wrong, those three views point at different causes - a blank page with a 404 status means the path has no route, a connection-refused page means the server is not running, and a security error on an https address means the scheme is wrong. The rule that ties them together is simple: the browser only ever sends the request, and the server decides everything about the answer. If you can read a response in the browser this way, you can test any route you add later without learning a new tool for it.