How to change hostname

hackerkatt

Member
Mar 20, 2021
7
0
6
61
I've got a fresh Proxmox 8.1.3 server. It is not part of a cluster and no vms or containers are set up or running. Only system updates performed. I'd like to change the hostname without having to reinstall the whole os from scratch. This documented method does not work: https://pve.proxmox.com/wiki/Renaming_a_PVE_node. It results in a web interface error Connection failed (Error 500: failed to get address info for: pve1: No address associated with hostname)

Out of curiosity, I asked ChatGPT... Steps listed were:

Code:
hostnamectl set-hostname newhostname
systemctl restart systemd-hostnamed
hostnamectl # to verify
nano /etc/hosts # modify existing host with new host
reboot

This resulted in the web interface breaking completely where the web interface would not load at all whereas the previous method found in the proxmox.com wiki resulted in the web interface loading and allowing login, but with the connection error. So I ssh into the server and run
Code:
systemctl status pveproxy

mynewhosthame pveproxy[1480]: /etc/pve/local/pve-ssl.key: failed to load local private key (key_file or key) at /usr/share/perl5/PVE/APIServer/AnyEvent.pm line 2009.

What's even odder is that the /etc/pve directory was completely empty. ChatGPT suggested I look for the /etc/pve/local/pve-ssl.key and even use pvecm updatecerts to update the ssl certs. Of course, the files seem to have vanished.

Now, even weirder is that when I reverted the hostname with
Code:
hostnamectl set-hostname theoldhostname
systemctl restart systemd-hostnamed
reboot

the /etc/pve files returned. Whaaaaaat?

I'm scratching me head. I gotta believe a hostname can be changed. It's not completely out of the realm of normal in a enterprise or homelab environment that a hostname would need to be changed short of a complete take down and reinstall of a server and it's services.

Thanks for any advise you might have

t.dema
 
Last edited:
Hey,
the /etc/pve folder is actually a virtual file system that is provided by the pve-cluster service. From the error messages you are getting, it seems like you still had a mismatch between /etc/hostname and /etc/hosts.
If you are using a long name hostname, make sure you are also resolving the short version, since that is gonna be used internally.

Code:
# /etc/hostname
foo.example.org
Code:
# /etc/hosts
192.168.0.10 foo.example.org foo
 
@Folke - Thank you for that clarification on the /etc/pve directory. Since I know this node is not part of a cluster then my assumption is that while that folder is provided by the pve-cluster service, it has nothing to do with whether the node is in a cluster or not.

I reverted back to the old hostname and everything was back to normal. I started over again, keeping it simple and it worked. What I failed to mention, and my apologies for not being absolutely clear, I was trying to set up a sub domain of a sub domain... In my attempt to obfuscate my post, I wasn't clear. I'm working on servers in my homelab. I want to set up Internal DNS and External DNS and use home as first subdomain. For example, I wanted to set the hostname to az5.home. And that's where I think things go south. When I set the hostname to az5 vs az5.home, the server comes up, web interface is working and the node name is correct. It's when I try to set it as az5.home that I experience the pveproxy service errors and the missing /etc/pve directory.

Thank you again...
 
@Folke - I did some more digging and found this post: https://forum.proxmox.com/threads/a...gui-or-started-containers.139866/#post-625126 where you suggest using journalctl -efu pve-cluster I added a the -x flag and found this in the output:

Jan 23 15:49:13 az5.home pmxcfs[1145]: [main] crit: Unable to resolve node name 'az5' to a non-loopback IP address - missing entry in '/etc/hosts' or DNS?

I edited the /etc/hosts file and added the az5 after az5.home which resolved the pve-cluster and pveproxy not coming up. I then followed the steps at the bottom of the https://pve.proxmox.com/wiki/Renaming_a_PVE_node wiki and copied the pve2-{node,storage}/az5 to pve2-{node,storage}/az5.home and then removed pve2-{node,storage}/az5.

So now az5 resolves to a non-loopback address, /var/lib/rrdcache/db/pve2-{node,storage}az5 has been moved. The web interface comes up with no errors.

After a reboot, the /var/lib/rrdcache/db/pve2-{node,storage}/az5 returns, is recreated.
And the node name remains az5.

I found these two posts of further interest:
https://forum.proxmox.com/threads/proxmox-node-name-change.14327/post-156444
https://forum.proxmox.com/threads/proxmox-node-name-change.14327/post-254015

I applied both methods independent of each other and still nothing works. If I leave the az5 in the /etc/hosts file, then everything comes up. BUT, the node name nor the terminal change. And, the /var/lib/rrdcache/db/pve2-node/az5 and /var/lib/rrdcache/db/pve2-storage/az5 entries reappear even though they were deleted. If I remove the az5 leaving only the az5.home.mydomain.com az5.home in the /etc/hosts file, then the cluster does not come up, the FUSE /etc/pve doesn't mount and the pveproxy fails to load.

I am a complete loss as to why this is such a difficult and misinformed process. There's so many differing understandings of how to change the hostname/node name and there seems to be a huge group of people who have the same problem but don't seem to have resolved.

Anybody? I see post after post after post regarding this issue and nobody seems to be able resolve this issue. Can the developers chime in here? Again, changing the hostname isn't a far out edge case scenario. I do get the added complexity of clustering and VM and LXC Container management and association. But this node isn't part of a cluster or have any VMs or Containers.

Thank you again!

# Current config

Bash:
root@az5:~# cat /etc/hostname
az5.home
root@az5:~#
root@az5:~# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
10.13.37.17 az5.home.mydomain.com az5.home az5

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
root@az5:~#
root@az5:~# hostnamectl
 Static hostname: az5.home
       Icon name: computer-server
         Chassis: server 
      Machine ID: 38f4d1ce3ea549eb8c78e1d10b4aad06
         Boot ID: b37baaff8c604481838a73bf133713d5
Operating System: Debian GNU/Linux 12 (bookworm)
          Kernel: Linux 6.5.11-7-pve
    Architecture: x86-64
 Hardware Vendor: Dell Inc.
  Hardware Model: PowerEdge R310
Firmware Version: 1.1.5
root@az5:~#
 
Last edited:
I've had the same problem and was able to resove it by:

First backup the data in hostname_old:
Code:
cp -R /etc/pve/nodes/hostname_old/ /root/

Next, move all the files and folders from the hostname_old folder to hostname_new:
Code:
mv /etc/pve/nodes/hostname_old/* /etc/pve/nodes/hostname_new/*

You might go through the below error:
Code:
mv: cannot move ‘/etc/pve/nodes/hostname_old/qemu-server’ to ‘/etc/pve/nodes/hostname_new/qemu-server/
qemu-server’: Directory not empty

Then need to move the file manually, and execute the below command:
Code:
mv /etc/pve/nodes/hostname_old/qemu-server/* /etc/pve/nodes/hostname_new/qemu-server/*

Source
 
I've had the same problem and was able to resove it by:

First backup the data in hostname_old:
Code:
cp -R /etc/pve/nodes/hostname_old/ /root/

Next, move all the files and folders from the hostname_old folder to hostname_new:
Code:
mv /etc/pve/nodes/hostname_old/* /etc/pve/nodes/hostname_new/*

You might go through the below error:
Code:
mv: cannot move ‘/etc/pve/nodes/hostname_old/qemu-server’ to ‘/etc/pve/nodes/hostname_new/qemu-server/
qemu-server’: Directory not empty

Then need to move the file manually, and execute the below command:
Code:
mv /etc/pve/nodes/hostname_old/qemu-server/* /etc/pve/nodes/hostname_new/qemu-server/*

Source
Will this let me change the host name with VMs currently on the node?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!