How to Change Your VPS Hostname

How to Change Your VPS Hostname

The hostname is the name assigned to your VPS. You may want to change it to match your domain name or server purpose.

Step 1: Connect to Your VPS via SSH

Login to your VPS using SSH:

ssh root@YOUR_VPS_IP

Enter your password when prompted.


Step 2: Check Current Hostname

To see the current hostname of your VPS, run:

hostname

Step 3: Change the Hostname

Use the following command to set a new hostname:

hostnamectl set-hostname your-new-hostname

Example:

hostnamectl set-hostname server1.example.com

Step 4: Update the Hosts File (Recommended)

Edit the hosts file:

nano /etc/hosts

Find the line similar to:

127.0.0.1 localhost

Add or update the hostname entry if needed.

Example:

127.0.0.1 localhost
127.0.1.1 server1.example.com server1

Save the file and exit.


Step 5: Verify the New Hostname

Run the following command to confirm the change:

hostnamectl

Your new hostname should now appear.


Important Notes

  • Hostname changes usually take effect immediately.

  • Some applications may require a server restart to recognize the new hostname.


If you need help changing your VPS hostname, please contact the Ateex Support Team.

Was this answer helpful?
0

Related Articles