How do I rename a Droplet or change its hostname?

Validated on 4 Oct 2022 • Last edited on 27 Sep 2023

To rename your Droplet, you need to change the Droplet’s name in the control panel. This changes the Droplet’s display name in the control panel and updates its rDNS record, but it doesn’t automatically update the hostname in the Droplet’s operating system. To change its hostname, you can either use hostnamectl or edit /etc/hostname and /etc/hosts manually.

Rename the Droplet

To rename the Droplet in the DigitalOcean Control Panel, log in and then click the Droplet you want to rename. In the Droplet detail window, click the name of the Droplet. Enter the new name in the entry field, then click the check mark to save it.

Alternatively, to rename the Droplet from the command line, use doctl compute droplet-action rename.

Change the Droplet’s Hostname

To update the Droplet’s hostname, use the hostname utility hostnamectl:

hostnamectl set-hostname use_your_new_hostname

If hostnamectl is not available on your Droplet, you can instead edit the /etc/hostname and /etc/hosts files. Open both files with sudo privileges, then replace any instances of the Droplet’s old hostname with the new hostname. After you save the files, reboot the Droplet to make the changes take effect.

You can use the hostname command to display the Droplet’s current hostname and verify the change.

How do I fix the "Could Not Translate Hostname to Address" error when connecting to PostgreSQL?

Verify the hostname and check your local machine for DNS resolution issues.

How do I fix the "Database Does Not Exist" error when connecting to PostgreSQL?

Verify the hostname and confirm the database exists in the specified cluster.

How do I fix the "Unknown Database" error when connecting to MySQL?

Ensure the hostname is correct and confirm the database exists in your specified cluster.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.