---
title: "Update server's hostname"
method: GET
path: "/sethostname"
tags: ["Server Administration", "System Information"]
---

# Update server's hostname

`GET /sethostname`

This function changes the server's hostname.

**Warning:**

* Do **not** select a hostname that begins with `www` or a number, or a
hostname that ends with a hyphen (`-`) character.
* You **must** use a fully-qualified domain name (FQDN) that contains two periods
(for example, `hostname.example.com`).
* Do **not** choose a hostname that a cPanel account on your server will use.
* Do **not** choose a potential service subdomain (proxy subdomain) as a hostname
(for example, `cpanel.example.com` or `whm.example.com`).

**Important:**

If you update your hostname, the system blocks user access to cPanel's [*Calendars and Contacts*](https://go.cpanel.net/calendars) interface (*cPanel >> Home >> Email >> Calendars and Contacts*).

The system restores access to this interface after the hostname update finishes.
For more information, read our
[Interface Lock Scripts](https://docs.cpanel.net/knowledge-base/cpanel-product/interface-lock-scripts/)
documentation.

**Note:**

Whenever you change the server's hostname, you **must** use one of the following methods:
  * Use WHM's
  [*Change Hostname*](https://docs.cpanel.net/whm/networking-setup/change-hostname/)
  interface (*WHM >> Home >> Networking Setup >> Change Hostname*).
  * Call WHM API 1's `sethostname` function.
  * Run the
  [`/usr/local/cpanel/bin/set_hostname` utility](https://docs.cpanel.net/whm/scripts/the-set_hostname-utility/)
  as the `root` user.
These methods ensure that all of the necessary system and service changes occur.

## Query parameters

- `hostname` string, hostname, required

## Response `200`

HTTP Request was successful.

- object
  - `metadata` object
    - `command` string — The method name called.
    - `output` object — A list of the function's output.
      - `messages` string — Any of the function's output messages.
      - `warnings` string — Any of the function's warnings.
    - `reason` string — The reason the API function failed when the `metadata.result` field is `0`. This field may display a success message when a function succeeds.
    - `result` 0 | 1 — * `1` — Success. * `0` — Failed. Check the `reason` field for more details.
    - `version` integer — The version of the API function.

---

[API](https://skmtc.net/cpanel/apis/whm-api.md) · [All operations](https://skmtc.net/cpanel/apis/whm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cpanel/whm-api/revisions/3da41671c02c/schema)
