---
title: "Changing the hostname of a Public Cloud instance"
description: "With the cloud-init module, you can configure your Public Cloud instance when you create it, and each time you reboot it. Consequently, if you wish to reconfigu"
url: https://docs.us.ovhcloud.com/en/public-cloud/compute/changing-the-hostname-of-an-instance
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# Changing the hostname of a Public Cloud instance

With the cloud-init module, you can configure your [Public Cloud instance](https://www.ovh.co.uk/public-cloud/instances/) when you create it, and each time you reboot it. Consequently, if you wish to reconfigure your hostname because of an error when creating your instance or to reconfigure your email server, you will need to disable the Cloud-init module. This will configure the hostname so that it is not re-established.

**Warning:**

**NOTE:** OVHcloud provides services for which you are responsible for their configuration and management. You are therefore responsible for their proper functioning.\
\
This tutorial is designed to help you as much as possible with common tasks. If you are having difficulty performing these actions, please contact a specialized service provider. OVHcloud cannot provide you with technical support in this regard.

**Warning:**

**NOTE:** This guide is for instances based on Linux distributions **only**.

 

## Requirements

- An [OVHcloud Public Cloud instance](https://docs.us.ovhcloud.com/en/public-cloud/compute/getting-started.md)
- [SSH access](https://docs.us.ovhcloud.com/en/public-cloud/compute/getting-started.md) (sudo) to the instance

 

## Instructions

### Disable the cloud-init module

**Note:**

For this guide, we will use the file editor **vi** because it is present by default on Linux distributions. You can use the editor of your choice.

Basic use of vi:

- Press **i** to enter text insertion mode.
- Press **Esc** (Esc) to exit insertion mode.
- Typ&#x65;**:** **wq** then **Enter** to save and exit.
- Typ&#x65;**:** **q!** then **Enter** to exit without saving.

To disable cloud-init, you will need to start by modifying the configuration file:

```
sudo vi /etc/cloud/cloud.cfg
```

Simply add the following two lines, or modify them if they already exist:

```
preserve_hostname: true
manage_etc_hosts: false
```

 

### Modify the hostname

The first step involves modifying the hostname. In this example, we will change the hostname to **webserver**. You can edit as it suits your preference:

```
sudo vi /etc/hostname
```

Add or replace content by:

```
webserver
```

Next, you will need to modify the `/etc/hosts` file:

```
sudo vi /etc/hosts
```

Add or replace content by:

```
127.0.1.1 webserver.localdomain webserver
127.0.0.1 localhost
```

You will then need to reboot the instance:

```bash
sudo reboot
```

After the reboot, the hostname modifications will be properly applied:

```
sudo cat /etc/hosts

127.0.1.1 webserver.localdomain webserver
127.0.0.1 localhost
```

 

## Go further

Browse all the [Compute guides](https://docs.us.ovhcloud.com/en/public-cloud/compute/landing-page-compute.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [Public Cloud Compute](https://us.ovhcloud.com/public-cloud/compute/) on the OVHcloud US website.
