All Products
Search
Document Center

Elastic Compute Service:Hostnames

Last Updated:May 15, 2026

Assign unique hostnames to ECS instances for identification, logging, and internal DNS resolution within a VPC.

Use cases

  • Distinguish instances: Identify individual ECS instances by meaningful names.

  • Simplify configuration: Use readable hostnames instead of IP addresses for network services, applications, and system settings.

  • Improve logging and monitoring: Hostnames in logs and monitoring tools identify event sources for faster troubleshooting.

  • Assist with DNS resolution: Map hostnames to IP addresses through internal DNS resolution so instances can communicate by hostname. See Use hostnames for internal communication between Linux instances.

Hostname types

Set an ECS instance hostname by configuring its Hostname Type. ECS supports the following hostname types:

  • Custom hostname: A hostname based on a custom string you provide.

    • Hostname format:

      • For Windows instances, the hostname must be 2 to 15 characters long. It can contain letters (uppercase or lowercase), digits, and hyphens (-), but cannot start or end with a hyphen, contain consecutive hyphens, or consist only of digits.

        Important

        Due to length constraints, Windows instances support only custom hostnames.

      • For other operating systems such as Linux, the hostname must be 2 to 64 characters long. Periods (.) separate segments. Each segment can contain letters (uppercase or lowercase), digits, and hyphens (-). The hostname cannot contain consecutive periods or hyphens, or start or end with a period or hyphen.

      Use a hostname that clearly indicates the server's purpose. A mature operations and maintenance (O&M) system typically includes a complete set of naming rules, such as `business ID-product line-region`. For example:

      • app001-live-huanan1 can indicate ECS server 001 in the `huanan1` region, which hosts the company's live streaming application.

      • jack001-dev-huabei2 can indicate development server 001 in the `huabei2` region, used by an employee named Jack.

    • Custom sequential hostnames: When creating multiple ECS instances, use sequential hostnames to differentiate and manage them. See Batch configure sequential instance names or hostnames.

  • IP address-based hostname: A non-editable hostname auto-generated from the primary private IPv4 address of the instance's primary elastic network interface (ENI). Suitable for environments that identify instances by IP address.

    Important

    If you change the primary private IPv4 address of an instance, the hostname updates automatically.

    • Hostname format: ip-[Private-IPv4-address-string].[regionID].ecs.internal

      • Private-IPv4-address-string: The primary private IPv4 address with periods (.) replaced by hyphens (-).

      • regionID: The region ID of the ECS instance. See Regions and zones.

      • ecs.internal: The internal domain suffix for ECS.

  • Instance ID-based hostname: A non-editable hostname auto-generated from the instance ID. This hostname persists even if the instance's IP address changes, making it ideal for stable identification.

    • Hostname format: [Instance-ID].[regionID].ecs.internal

Configure an instance hostname

If you do not specify a hostname during instance creation, a default custom hostname is assigned.

Define a hostname during creation or modify it afterward.

Define during creation

  1. Go to ECS console - custom launch.

  2. Configure settings such as the billing method, region, instance type, and image.

    For a detailed explanation of each parameter, see Parameters.

  3. Click Advanced Settings (Optional) to define a hostname. To create multiple instances, batch configure sequential instance names or hostnames to differentiate them.

    Important

    Due to length constraints, Windows instances support only custom hostnames.

    image

Modify after creation

Important
  • You can also call the ModifyInstanceAttribute API operation to modify the hostname.

  • After modifying a hostname, restart the instance from the ECS console (see Restart an instance) or by calling the RebootInstance API operation for the change to take effect. Restarting from within the operating system does not guarantee that the change takes effect.

  • Do not modify the hostname from within the operating system (such as running hostnamectl or editing /etc/hostname). Such changes are not synced with instance properties and will not appear in the ECS console or API.

  1. Go to ECS console - Instances.

  2. Click the instance ID to open its details page. In the upper-right corner, click All Operations > Modify Instance Properties. Modify the hostname and click OK.

    Important

    Due to length constraints, Windows instances support only custom hostnames.

    image

  3. Restart the instance for the hostname change to take effect.

View an instance hostname

View the hostname in the ECS console or by running the hostname command on the instance.

View in the console

View the hostname on the instance details page.

  1. Go to ECS console - Instances.

  2. Click the instance ID to open the details page. In the Other Information > Host Name.

    image

API references

Call the DescribeInstances operation and check the HostName parameter in the response.

Connect to view

Connect to an ECS instance to view its system hostname.

  1. Connect to the instance.

  2. View the system hostname:

    hostname

    image

Use hostnames for internal communication between Linux instances

Enable internal communication between two ECS instances in the same VPC and security group by using hostnames.

Basic information

  • Target instance: The instance with hostname and private DNS resolution configured.

    • Operating system: Alibaba Cloud Linux 3.2

    • Primary private IPv4 address: 172.16.0.101

  • Test instance: The instance that runs ping <target_instance_hostname> to access the target instance.

    • Operating system: Alibaba Cloud Linux 3.2

    • Primary private IPv4 address: 172.16.100.170

Procedure

  1. Configure the hostname of the target instance to be IP-based (or instance ID-based). See Configure an instance hostname.

    image

  2. Restart the target instance for the new hostname to take effect.

  3. Verify the hostname of the target instance.

    1. Connect to the target instance.

      See Log on to a Linux instance using Workbench.

    2. Check the current hostname of the target instance:

      hostname

      The following output indicates the hostname is updated:

      image

  4. Configure private DNS resolution for the target instance. See Enable communication between ECS instances by using private domain names.

    1. In the VPC console, enable the DNS hostname feature for the VPC.

      Enable hostname

    2. In the ECS console, configure private DNS resolution for the target instance. Select Enable DNS resolution for the IP-based hostname to the primary private IPv4 address of the instance (A record):

      image

  5. Log on to the test instance and run ping <target_instance_hostname> to test connectivity.

    1. Connect to the test instance with Workbench. See Log on to a Linux instance using Workbench.

    2. Verify internal network connectivity to the target instance by hostname:

      ping ip-172-16-0-101.ap-southeast-3.ecs.internal

      The following output shows the instance is accessible over the internal network by hostname:

      image