When creating a new Vultr VPS, you can set the Server Hostname before deployment. If you skip this step or decide to rename your server later, you'll discover that changing the server hostname from the Customer Portal also performs a fresh reinstall of the entire server.
Follow this guide if you need to change the server hostname without reinstalling.
This guide uses olddog for the old hostname and newtricks for the new hostname.
Check the hostname with hostname
.
$ hostname
olddog
You can also use hostnamectl
.
$ hostnamectl
Static hostname: olddog
Change the hostname to newtricks.
$ sudo hostnamectl set-hostname newtricks
Use your favorite text editor to change any instances of your old hostname to the new hostname in /etc/hosts
. If you have a DNS name pointed to this instance, it's a best practice to also set that name here.
$ sudo nano /etc/hosts
From:
127.0.0.1 olddog
::1 olddog
To:
127.0.0.1 newtricks newtricks.example.com
::1 newtricks newtricks.example.com
Reboot the server.
Test your change with hostnamectl
and hostname
.
$ hostnamectl
Static hostname: newtricks
$ hostname
newtricks
$ hostname -a
newtricks.example.com
Your server hostname is changed and ready to use. This procedure does not change your DNS name, and you'll need to perform those steps at your domain registrar.