How to Change the Hostname of a Vultr Cloud Instance
How to Change the Hostname of a Vultr Cloud Instance
Learn how to change the hostname on CentOS, Fedora, Ubuntu, Debian, FreeBSD, and Windows Server systems without reinstalling or losing data, while ensuring the new name persists across reboots and cloud-init resets.

A hostname is a name that is given to a system within a network to uniquely identify it among other devices. It serves as a human-readable label that simplifies communication, troubleshooting, and management. Instead of remembering IP addresses, administrators and users can reference machines using recognizable names like web01, db-server, or node1.example.com.
Hostname are important for:
- DNS resolution
- SSH access
- Monitoring and logging
Changing the hostname is a common task when setting up new servers, applying naming conventions, or preparing systems for production environments.
Changing the hostname using the Vultr Customer Portal triggers a full server reinstall because it uses cloud-init to set the hostname during provisioning. This process erases all data on the server, including the operating system and files.
Follow this guide to change the hostname on CentOS, Fedora, FreeBSD, Ubuntu, and Windows Server without reinstalling the server or losing any data.
Prerequisites
Before you begin, you need to:
- Have access to a Linux server as a non-root user with sudo privileges.
Disable the Automatic Hostname Update
To make your hostname changes permanent, remove the hostname related directives from the /etc/cloud/cloud.cfg file. This prevents cloud-init from resetting the hostname on reboot.
- Open the
/etc/cloud/cloud.cfgfile using an test editor.console$ sudo nano /etc/cloud/cloud.cfg - Locate the
cloud_init_modulessection and remove the following directives.- set_hostname - update_hostname - update_etc_hostsSave and close the file.
hostname on CentOS and Fedora.Follow the steps below to change the hostname on RHEL-based distros like CentOS or Fedora.
- View the
hostnameof your server.console$ hostnameYour output should be similar to the one below:
my-hostname - Change the server
hostnameby running the following command.console$ sudo hostnamectl set-hostname my-new-hostnameReplace
my-new-hostnamewith the new hostname you want to set. - Update the
/etc/hostsfile with the newhostname. Also if you have a DNS entry then the best practice is to update the name in this file as well.console$ sudo nano /etc/hostsAfter updating, the file should be similar to the one below:
... 127.0.0.1 my-new-hostname my-new-hostname.example.com 127.0.0.1 localhost.localdomain localhost ... - Reboot the server to apply the changes.
console
$ sudo reboot - Verify that your
hostnamechanges are reflected on the server.console$ hostnamectlOutput:
Static hostname: my-new-hostname ... - Verify that your hosts file changes is also reflected.
console
$ cat /etc/hostsYour output should be similar to the one below:
... 127.0.1.1 my-new-hostname my-new-hostname.example.com 127.0.0.1 localhost ... Change the hostname on Ubuntu oN DebianFollow the steps below to change the hostname on Ubuntu or other Debian-based distributions without reinstalling the system or losing any data.
- View the
hostnameof your server.console$ hostnameYour output should be similar to the one below:
my-hostname - Change the
hostnameusing thehostnamectlcommand.console$ sudo hostnamectl set-hostname my-new-hostnameReplace
my-new-hostnamewith the new hostname you want to set. - Update the
/etc/hostsfile with the newhostname. Also if you have a DNS entry then the best practice is to update the name in this file as well.console$ sudo nano /etc/hostsAfter updating, the file should be similar to the one below:
... 127.0.1.1 my-new-hostname my-new-hostname.example.com 127.0.0.1 localhost ... - Reboot the server to apply the changes.
console
$ sudo reboot - After rebooting, verify that the
hostnameand hosts file changes are applied.console$ hostnamectl $ cat /etc/hosts
The above commands should display your new
hostnamein both the system configuration and the/etc/hostsfile, confirming that the changes are reflected and is persistent.
Change thehostnameon FreeBSDFollow the steps below to change the
hostnameon a FreeBSD system.- View the hostname of your server.
console
$ hostnameYour output should be similar to the one below:
my-hostname - Edit the
/etc/rc.conffile to update the serverhostname.console$ sudo vim /etc/rc.confYour updated configuration file should be similar to the one below:
hostname="my-new-hostname" sshd_enable="YES" ...Replace
my-new-hostnamewith the new hostname you want to set. - Update the
/etc/hostsfile to include the newhostname.console$ sudo vim /etc/hostsAfter updating, the file should be similar to the one below:
... 127.0.0.1 my-new-hostname my-new-hostname.example.com ::1 my-new-hostname ... - Reboot your system to apply the changes.
console
$ sudo reboot - After reboot, verify that your
hostnameand hosts related changes are reflected.console$ hostname $ cat /etc/hosts
This above commands should display the new
hostnameand your hosts file with new changes.
Change the hostname on Windows ServerFollow the steps below to change the hostname on Windows Server using either PowerShell or the graphical interface.
NoteBefore changing the hostname, ensure that no critical roles are already installed. Renaming a system with configured roles such as a domain controller or Exchange server can lead to conflicts. Always create a snapshot or backup before proceeding.
Change the Hostname Using PowerShell
Follow the steps below to change the Windows server hostname using Powershell.
- Open the Windows PowerShell as an administrator.
- View the Windows server hostname.
pwsh
PS C:\> $env:COMPUTERNAME
Output:
MY-HOSTNAME - Change the Windows server hostname.
pwsh
PS C:\> Rename-Computer -NewName "MY-NEW-HOSTNAME" -Restart
Replace
MY-NEW-HOSTNAMEwith your desired hostname. The-Restartparameter restarts the server to apply the change. - After the system reboots, verify the hostname.
pwsh
PS C:\> $env:COMPUTERNAME
Output:
MY-NEW-HOSTNAME
Change the Hostname Using the Windows GUI
- Log in to your server using Remote Desktop (RDP).
- Open File Explorer, right click This PC, and select Properties.
- In the Properties window, go to the System section and open the About page.
- Click the Rename this PC button.
- Enter the new hostname and click Next.
- Click Restart now to restart the server and44444 apply the changes.
Conclusion
In this guide, you changed the hostname across multiple operating systems without reinstalling your server or losing data. You updated the hostname configuration on CentOS, Fedora, FreeBSD, Ubuntu, and Windows Server using system-specific tools and disabled cloud-init to prevent overwrites. These steps ensured the changes persisted across reboots and followed best practices for system administration.
- View the