# Changing the Hostname

**URL:** https://community.ovhcloud.com/t/changing-the-hostname/4563
**Category:** Public Cloud
**Created:** [Juin 6, 2024, 3:42 UTC](https://community.ovhcloud.com/t/changing-the-hostname/4563 "2024-06-06T15:42:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ilyabakhlinlebedev](https://community.ovhcloud.com/letter_avatar/ilyabakhlinlebedev/32/5_5575768a8748004e209b776fc1b2916d.png) [@ilyabakhlinlebedev](https://community.ovhcloud.com/u/ilyabakhlinlebedev)
#### Post date: [Juin 6, 2024, 3:42 UTC](https://community.ovhcloud.com/t/changing-the-hostname/4563/1 "2024-06-06T15:42:35Z")

</div>

Hello, OVH Community.  
  
I've got a brand new VPS and I'm setting everything up.  
  
However, I've found myself in a little trouble, when trying to rename my VPS' hostname.  
  
I've followed the following steps:  
  
1. Follow [this guide](https://help.ovhcloud.com/csm/es-es-public-cloud-compute-chang-instance-hostname?id=kb_article_view&sysparm_article=KB0050565) and edit the `/etc/cloud/cloud.cfg` file, adding and changing the following lines:  
  
```  
preserve\_hostname: true  
manage\_etc\_hosts: false  
```  
  
2. Use the `hostnamectl` command as follows:  
  
```  
hostnamectl set-hostname subdomain.domain.tld  
```  
  
3. Edit the `/etc/hosts` file accordingly.  
  
However, after a reboot, if I access the `/etc/hosts` file, it preserves all the changes, but keeps adding the following line:  
  
```  
127.0.1.1 [vps-XXXXXXXX.vps.ovh.net](http://vps-XXXXXXXX.vps.ovh.net) vps-XXXXXXXX  
```  
  
What is the precise procedure to rename your virtual private server?  
  
Regards.

---

<div class="post-metadata">

### Author: ![system](https://community.ovhcloud.com/user_avatar/community.ovhcloud.com/system/32/5_2.png) [@system](https://community.ovhcloud.com/u/system)
#### Post date: [Avril 29, 2025, 10:57 UTC](https://community.ovhcloud.com/t/changing-the-hostname/4563/2 "2025-04-29T10:57:05Z")

</div>

Hi,

1. comment out the '-update\_etc\_hosts' parameter in the '/etc/cloud/cloud.cfg' file .
2. Use the `hostnamectl` command as follows: hostnamectl set-hostname [hostname.domain]
3. edit the `/etc/hosts`

that's how it works for me.

Tested on almalinux and centos.
