How to change the hostname of a Cloud Server

Published on: December 4, 2026

A Cloud Server's hostname is stored in two places: in the Control Panel and in the server's operating system. When you deploy a server, the operating system takes the hostname from the Control Panel the first time it starts. After that, the two are kept separately, so changing the hostname in the Control Panel doesn't change it on the server, even after a restart.

To change a server's hostname, you change it in the Control Panel and then on the server itself. This guide walks you through both on a Linux Cloud Server deployed from one of UpCloud's templates. The examples use web1.example.com as the current hostname and web2.example.com as the new one.

Change the hostname in the Control Panel

Changing the hostname in the Control Panel keeps the server's details up to date, so the Control Panel and the UpCloud API show the new name. You can change it while the server is running.

  1. In the Control Panel, go to Servers and select the server.
  2. On the Overview tab, click the pencil icon next to Hostname.
  3. Enter the new hostname, such as web2.example.com, and click the checkmark icon to save it.

The server's metadata service returns the new hostname after you next restart the server from the Control Panel. The operating system, however, keeps its current hostname until you change it on the server, as described in the next section.

Change the hostname on the server

Connect to the server over SSH, as described in Connecting to your Cloud Server. Before you set the new hostname, check whether the server uses the short name or the full name with the following command:

hostname

If the command prints the short name, such as web1, set the new short name with:

sudo hostnamectl set-hostname web2

If it prints the full name, such as web1.example.com, set the new full name with:

sudo hostnamectl set-hostname web2.example.com

On some servers, sudo warns that it's unable to resolve the host:

Output
sudo: unable to resolve host web1.example.com: No address associated with hostname

The command still sets the new hostname. The warning appears because the hosts file has no line for the hostname yet, and it stops once you've updated the hosts file in the next step.

Update the hosts file

The server looks up its own name in the /etc/hosts file, so the file needs the new hostname as well. Open the file in a text editor:

sudo nano /etc/hosts

On servers that use cloud-init, the file starts with a comment saying that manage_etc_hosts is set and that changes to the file won't persist. On UpCloud's templates, cloud-init writes the file only when the server is first deployed, so your changes stay after a restart.

Replace the old hostname with the new one wherever it appears, both the full name and the short name. Depending on the operating system, the hostname is on one line or on two lines. With the new hostname, a single line looks like this:

127.0.1.1 web2.example.com web2

Two lines look like this:

127.0.0.1 web2.example.com web2
::1 web2.example.com web2

If no line has the old hostname, add the following line to the end of the file:

127.0.1.1 web2.example.com web2

Save the file and close the editor.

Check the new hostname

The new hostname takes effect immediately, without a restart. To check it, run:

hostname

The command prints the new hostname:

Output
web2

Then check that the server can look up its new name:

getent hosts web2

The command prints an address from the hosts file, followed by the new hostname:

Output
127.0.1.1       web2.example.com web2

Your shell prompt shows the new hostname the next time you log in. The server keeps the new hostname when you restart it.

Contributed by: Samir Haliru

Can't find what you're looking for?

For more help you can contact our awesome 24/7 support team

Contact Support