How do I change the hostname of my Smart VPS?

Your VPS has a hostname: the name it shows in the portal and in logs, and the one you probably want on your prompt and in your mail headers. You can change the portal's copy in about ten seconds. The name inside the operating system is a separate setting, so this article covers both.

What is a hostname?

A hostname is the name your server calls itself, such as web1.example.com. It shows up in your shell prompt, in system logs, in the headers of email your server sends, and in the portal. It is just a label. It doesn't create any DNS records by itself, and nothing on the internet will find your server by that name until you add an A record for it at your DNS provider.

Two places, two settings

  • The portal hostname is what you see on the Overview tab of your VPS. Changing it here updates the name the portal shows.
  • The operating system hostname is what the server itself reports (hostname, your shell prompt, mail headers). It lives inside the VPS, so you set it with a command after you log in.

Set both to the same name so nobody has to wonder which one is right.

Steps

  • Pick a fully qualified name you control, like web1.example.com. Letters, numbers and hyphens only, no spaces.
  • The portal can take up to a minute to save the new name, and the Edit link is only there while the VPS is idle.
  • If this IP sends email, the hostname should match the reverse DNS (PTR) record. See the related article below.

Change the portal hostname

  1. Log in to the portal at https://noc.versaweb.com.
  2. Click Services, then Smart VPS Servers, then click your VPS.
  3. On the Overview tab, find the Hostname row and click Edit.

The Overview tab of a Smart VPS, showing the Hostname row with its Edit link

  1. Type the new hostname into the box that appears.

The Hostname row turned into a text box with a Save link

  1. Click Save. The row says it's updating for up to a minute. Reload the page to see the new name.

The Overview tab after saving, showing the new hostname

Change the hostname inside the operating system

Log in over SSH (or the console) as root and run the following. Replace web1.example.com with your name.

  1. Set the name: hostnamectl set-hostname web1.example.com
  2. Open /etc/hosts (for example nano /etc/hosts) and make sure the line for your server lists the new name. On Debian that is usually the second line, the one the image added for the server's own name. It should end with your new name and its short form, for example web1.example.com web1. The image manages this file with cloud-init, so the change may not survive a reboot unless you also keep the hostname setting in /etc/cloud/cloud.cfg (preserve_hostname: true).
  3. Check it: hostname -f should print the new name.

How to check it worked

  • The Overview tab shows the new name in the Hostname row.
  • hostname -f on the server prints the same name.
  • If you also want the name to resolve, dig +short web1.example.com should return your VPS's IP address once you've added the A record.

If it didn't work

  • Save did nothing. Reload the page and check the Overview tab again. If the old name is back, try once more; if that fails, open a ticket.
  • The prompt still shows the old name. Log out and back in. If it still does, run hostnamectl and check the Static hostname line.
  • Mail from the server is being rejected. Check that the hostname, the A record and the reverse DNS all agree.
  • Still stuck? Open a ticket under Technical Support with your IP address and the name you want.

Related articles


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 1