How can I change the hostname after install?

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

My System:
Raspberry Pi 5, 8G
1T Nvme drive

The Basics

  • Nextcloud Server version:
    -29.0.3
  • Operating system and version (e.g., Ubuntu 24.04):
    • Nextcloudpi 1.55.2
    • Debian bookworm
  • PHP version (e.g, 8.3):
    • 8.3
  • When did this problem seem to first start?
    • on installation
  • Installation method (e.g. AIO, NCP, Bare Metal/Archive, etc.)
    • Raspberry Pi Imager

Summary of the issue you are facing:

After successfully installing NextcloudPi to my Nvme card and setting up the system, it comes up with ‘nextcloudpi’ as the hostname.
I want to know how I can successfully change the host name.

What I have tried:

  1. Searched the forums and internet for any clues. No luck.
  2. Tried using the ‘hostname’ command to alter the name, but it leads to nextcloud mis-configuration.
  3. I tried editing the etc/hosts file and changing the hostname there, but that fails because there are other nextcloud config files that contain the hostname. Ex: /var/www/nextcloud/config/config.php. I don’t know what other config files would need to be changed.

Steps to replicate it (hint: details matter!):

  1. Install Nextcloudpi on a RaspberryPi.
  2. Examine hostname

Is there a utility or setup script that will correctly change the hostname?

Changing the hostname to something else seems like it would be a common use-case. Has anyone successfully done this?

Thanks

1 Like

Take a look:

hostnamectl

But keep in mind it is a server not a baby. NCP approach to ux should stay on push button - be happy.
Maybe you file a feature request on nc’s github. :wink:

Thanks for the ‘hostnamectl’ command! I’ve been using Linux for 20 years and didn’t remember that one.

I had achieved the same result by editing the /etc/hostname and /etc/hosts files manually.

Thanks again.

To change the hostname on your NextcloudPi setup:

  1. Use hostnamectl to change the system’s hostname.
  2. Update the /etc/hosts file to reflect the new hostname.
  3. Modify the Nextcloud configuration (config.php) to update any references to the old hostname under trusted_domains.
  4. If using Apache or Nginx, ensure the hostname is updated in their respective configuration files.
  5. Reboot your Raspberry Pi to apply the changes.

These steps should successfully change the hostname without causing issues.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.