# Troubleshooting in Compute Cloud

* [I cannot connect to a new VM with multiple network interfaces over SSH](#unable-to-connect-to-new-multi-interface-vm).

* [My VM fails to start after I update its configuration](#not-starting).

* [My VM fails to start after I stop it](#not-starting-after-stop).

* [My VM fails to start after I update its disk type](#not-starting-after-disk-change).

* [My VM fails to start after I update its disk size](#not-starting-after-disk-resize).

* [My VM fails to start after I update its vCPU number](#not-starting-after-cpu-change).

* [My VM fails to start after I update its vRAM amount](#not-starting-after-ram-change).

* [My VM fails to start after I update its metadata](#not-starting-after-metadata-change).

* [My VM fails to start after I update its security group](#not-starting-after-security-group-change).

* [My VM fails to start after I update its network](#not-starting-after-network-change).

This section describes typical problems that may arise when using Compute Cloud and the relevant solutions.

#### You cannot connect to a new VM with multiple network interfaces over SSH {#unable-to-connect-to-new-multi-interface-vm}

When creating a Linux VM with multiple [network interfaces](../concepts/network.md), the additional network interfaces may not work correctly in the OS. In some cases, this issue can hinder network connectivity and prevent you from [connecting](../operations/vm-connect/ssh.md) to your VM over SSH.

{% note alert %}

To access the VM's contents one must have the relevant user credentials, e.g., SSH keys. This means the Yandex Cloud support does not have access to your VM's OS for security and user data privacy reasons.

{% endnote %}

To fix it, delete the VM and [create](../operations/vm-create/create-linux-vm.md) a new one by providing additional [cloud-init](https://cloud-init.io) parameters in the new VM [metadata](../concepts/vm-metadata.md#keys-processed-in-public-images):

{% list tabs group=instructions %}

- Management console {#console}

  Expand the **Metadata** section and add the `user-data` key with the following configuration:

  {% cut "For Ubuntu" %}

  In the `write_files.content.network.ethernets` configuration section, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
  
  ```yaml
  #cloud-config
  
  datasource:
    Ec2:
      strict_id: false
  ssh_pwauth: yes
  users:
    - name: <username>
      sudo: ALL=(ALL) NOPASSWD:ALL
      shell: /bin/bash
      ssh_authorized_keys:
        - <public_SSH_key>
  write_files:
    - path: "/etc/netplan/01-netcfg.yaml"
      permissions: "0644"
      content: |
        # This file describes the network interfaces available on your system
        # For more information, see netplan(5).
        network:
          version: 2
          renderer: networkd
          ethernets:
            eth0:
              dhcp4: yes
            eth1:
              dhcp4: yes
              dhcp4-overrides:
                use-dns: false
                use-routes: false
              dhcp6: no
            eth2:
              dhcp4: yes
              dhcp4-overrides:
                use-dns: false
                use-routes: false
              dhcp6: no
  runcmd:
    - sleep 1
    - sudo -i
    - netplan apply
  ```

  {% endcut %}

  {% cut "For Debian" %}

  In the `Primary network interface` and `Other network interfaces` configuration sections, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
  
  ```yaml
  #cloud-config
  
  datasource:
    Ec2:
      strict_id: false
  ssh_pwauth: yes
  users:
    - name: <username>
      sudo: ALL=(ALL) NOPASSWD:ALL
      shell: /bin/bash
      ssh_authorized_keys:
        - <public_SSH_key>
  write_files:
    - path: "/etc/network/interfaces"
      permissions: "0644"
      content: |
        # This file describes the network interfaces available on your system
        # and how to activate them. For more information, see interfaces(5).
  
        source /etc/network/interfaces.d/*
  
        # Loopback network interface
        auto lo
        iface lo inet loopback
  
        # Primary network interface
        allow-hotplug eth0
        iface eth0 inet dhcp
  
        # Other network interfaces
        auto eth1
        allow-hotplug eth1
        iface eth1 inet dhcp
  
        auto eth2
        allow-hotplug eth2
        iface eth2 inet dhcp
        post-up ip route del default
  runcmd:
    - sleep 1
    - sudo -i
    - systemctl restart networking
  ```

  {% endcut %}

  Where:
  * `name:`: Username for [connecting](../operations/vm-connect/ssh.md) to the VM over SSH.
  * `ssh_authorized_keys:`: List of public SSH keys to connect the user to the VM over SSH. Specify at least one public SSH key.

- CLI {#cli}

  1. Create a file with the `cloud-init` configuration, e.g., `vm-init.tpl`:

      {% cut "For Ubuntu" %}

      In the `write_files.content.network.ethernets` configuration section, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
      
      ```yaml
      #cloud-config
      
      datasource:
        Ec2:
          strict_id: false
      ssh_pwauth: yes
      users:
        - name: <username>
          sudo: ALL=(ALL) NOPASSWD:ALL
          shell: /bin/bash
          ssh_authorized_keys:
            - <public_SSH_key>
      write_files:
        - path: "/etc/netplan/01-netcfg.yaml"
          permissions: "0644"
          content: |
            # This file describes the network interfaces available on your system
            # For more information, see netplan(5).
            network:
              version: 2
              renderer: networkd
              ethernets:
                eth0:
                  dhcp4: yes
                eth1:
                  dhcp4: yes
                  dhcp4-overrides:
                    use-dns: false
                    use-routes: false
                  dhcp6: no
                eth2:
                  dhcp4: yes
                  dhcp4-overrides:
                    use-dns: false
                    use-routes: false
                  dhcp6: no
      runcmd:
        - sleep 1
        - sudo -i
        - netplan apply
      ```

      {% endcut %}

      {% cut "For Debian" %}

      In the `Primary network interface` and `Other network interfaces` configuration sections, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
      
      ```yaml
      #cloud-config
      
      datasource:
        Ec2:
          strict_id: false
      ssh_pwauth: yes
      users:
        - name: <username>
          sudo: ALL=(ALL) NOPASSWD:ALL
          shell: /bin/bash
          ssh_authorized_keys:
            - <public_SSH_key>
      write_files:
        - path: "/etc/network/interfaces"
          permissions: "0644"
          content: |
            # This file describes the network interfaces available on your system
            # and how to activate them. For more information, see interfaces(5).
      
            source /etc/network/interfaces.d/*
      
            # Loopback network interface
            auto lo
            iface lo inet loopback
      
            # Primary network interface
            allow-hotplug eth0
            iface eth0 inet dhcp
      
            # Other network interfaces
            auto eth1
            allow-hotplug eth1
            iface eth1 inet dhcp
      
            auto eth2
            allow-hotplug eth2
            iface eth2 inet dhcp
            post-up ip route del default
      runcmd:
        - sleep 1
        - sudo -i
        - systemctl restart networking
      ```

      {% endcut %}

  1. When creating a VM, provide the created configuration file in the `--metadata-from-file` parameter. Here is an example:

      ```bash
      yc compute instance create --name=multi-net-vm --hostname=multi-net-vm \
        --zone ru-central1-a \
        --create-boot-disk image-folder-id=standard-images,image-id=fd8bi0vgcf8vco49q3bm \
        --cores=2 --memory=4G --core-fraction=100 \
        --network-interface subnet-name=subnet1,ipv4-address=auto,nat-ip-version=ipv4 \
        --network-interface subnet-name=subnet2,ipv4-address=auto \
        --network-interface subnet-name=subnet3,ipv4-address=auto \
        --metadata-from-file user-data=vm-init.tpl
      ```

      {% note info %}
      
      The commands [`yc compute instance create`](../../cli/cli-ref/compute/cli-ref/instance/create.md) | [`create-with-container`](../../cli/cli-ref/compute/cli-ref/instance/create-with-container.md) | [`update`](../../cli/cli-ref/compute/cli-ref/instance/update.md) | [`add-metadata`](../../cli/cli-ref/compute/cli-ref/instance/add-metadata.md) support substitution of environment variable values into VM metadata. When you execute a Yandex Cloud CLI command, these values, specified in the `user-data` key in `$<variable_name>` format, will be substituted into the VM metadata from the environment variables of the environment the command is executed in. 
      
      To change such behavior, i.e. to provide a variable name to the VM metadata in `$<variable_name>` format rather than take the variable value from the CLI command runtime environment, use the two-dollar syntax, e.g., `$$<variable_name>`.
      
      For more information, see [Specifics of providing environment variables in metadata via the CLI](../concepts/metadata/sending-metadata.md#environment-variables).
      
      {% endnote %}

- Terraform {#tf}

  1. Create a file with the `cloud-init` configuration, e.g., `vm-init.tpl`:

      {% cut "For Ubuntu" %}

      In the `write_files.content.network.ethernets` configuration section, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
      
      ```yaml
      #cloud-config
      
      datasource:
        Ec2:
          strict_id: false
      ssh_pwauth: yes
      users:
        - name: <username>
          sudo: ALL=(ALL) NOPASSWD:ALL
          shell: /bin/bash
          ssh_authorized_keys:
            - <public_SSH_key>
      write_files:
        - path: "/etc/netplan/01-netcfg.yaml"
          permissions: "0644"
          content: |
            # This file describes the network interfaces available on your system
            # For more information, see netplan(5).
            network:
              version: 2
              renderer: networkd
              ethernets:
                eth0:
                  dhcp4: yes
                eth1:
                  dhcp4: yes
                  dhcp4-overrides:
                    use-dns: false
                    use-routes: false
                  dhcp6: no
                eth2:
                  dhcp4: yes
                  dhcp4-overrides:
                    use-dns: false
                    use-routes: false
                  dhcp6: no
      runcmd:
        - sleep 1
        - sudo -i
        - netplan apply
      ```

      {% endcut %}

      {% cut "For Debian" %}

      In the `Primary network interface` and `Other network interfaces` configuration sections, specify the settings for the required number of network interfaces you want to create on this VM, as shown below. Interfaces are numbered starting from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.
      
      ```yaml
      #cloud-config
      
      datasource:
        Ec2:
          strict_id: false
      ssh_pwauth: yes
      users:
        - name: <username>
          sudo: ALL=(ALL) NOPASSWD:ALL
          shell: /bin/bash
          ssh_authorized_keys:
            - <public_SSH_key>
      write_files:
        - path: "/etc/network/interfaces"
          permissions: "0644"
          content: |
            # This file describes the network interfaces available on your system
            # and how to activate them. For more information, see interfaces(5).
      
            source /etc/network/interfaces.d/*
      
            # Loopback network interface
            auto lo
            iface lo inet loopback
      
            # Primary network interface
            allow-hotplug eth0
            iface eth0 inet dhcp
      
            # Other network interfaces
            auto eth1
            allow-hotplug eth1
            iface eth1 inet dhcp
      
            auto eth2
            allow-hotplug eth2
            iface eth2 inet dhcp
            post-up ip route del default
      runcmd:
        - sleep 1
        - sudo -i
        - systemctl restart networking
      ```

      {% endcut %}

  1. When creating a VM, provide the created metadata file in the `yandex_compute_instance.metadata` section. Here is an example:

      ```hcl
      resource "yandex_compute_instance" "multi-net-vm" {
        name        = "multi-net-vm"
        platform_id = "standard-v2"
        zone        = "ru-central1-a"
       
        resources {
          cores  = "2"
          memory = "2"
        }

        boot_disk {
          initialize_params {
            image_id = "fd8bi0vgcf8vco49q3bm"
          }
        }

        network_interface {
          subnet_id          = "e2lrucutusnd********"
          nat                = true
        }

        network_interface {
          subnet_id          = "e2lpp96bvvgp********"
          nat                = false
        }

        network_interface {
          subnet_id          = "e2lv9c6aek1d********"
          nat                = false
        }

        metadata = {
          user-data = "${file("./vm-init.tpl")}"
        }
      }
      ```

{% endlist %}

#### Additional network interfaces do not work after you attach them to an existing VM {#added-net-interfaces-down}

After you attach additional [network interfaces](../concepts/network.md) to a Linux VM, they may not work correctly in the operating system. In some cases, this issue can hinder network connectivity and prevent you from connecting to your VM over SSH.

To fix it, try upgrading the VM's operating system to its latest version.

If upgrading the OS is not possible or does not help:

1. [Connect](../operations/vm-connect/ssh.md) to the VM over SSH.

    If the SSH connection fails due to network connectivity issues, [remove](../operations/vm-control/detach-network-interface.md) all additional network interfaces and [reboot](../operations/vm-control/vm-stop-and-start.md#restart) the VM.

1. Update the OS network configuration:

    {% list tabs %}

    - Ubuntu

      1. Add the configuration of the new network interfaces to the `/etc/netplan/01-netcfg.yaml` file:
      
          ```bash
          sudo nano /etc/netplan/01-netcfg.yaml
          ```

          In the `write_files.content.network.ethernets` configuration section, specify the settings for the required number of existing or new VM network interfaces, as shown below. Interface numbering starts from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.

          ```
          # This file describes the network interfaces available on your system
          # For more information, see netplan(5).
          network:
            version: 2
            renderer: networkd
            ethernets:
              eth0:
                dhcp4: yes
              eth1:
                dhcp4: yes
                dhcp4-overrides:
                  use-dns: false
                  use-routes: false
                dhcp6: no
              eth2:
                dhcp4: yes
                dhcp4-overrides:
                  use-dns: false
                  use-routes: false
                dhcp6: no
          ```

      1. Assign the required permissions to the `/etc/netplan/01-netcfg.yaml` file:

          ```bash
          sudo chmod 0644 /etc/netplan/01-netcfg.yaml
          ```

      1. Apply the network configuration changes:

          ```bash
          sudo netplan apply
          ```

    - Debian

      1. Add the configuration of the new network interfaces to the `/etc/network/interfaces` file:
      
          ```bash
          sudo nano /etc/network/interfaces
          ```
      
          In the `Primary network interface` and `Other network interfaces` configuration sections, specify the settings for the required number of existing or new VM network interfaces, as shown below. Interface numbering starts from zero. This example shows how to set up three interfaces. You can add up to eight network interfaces to a single VM.

          ```txt
          # This file describes the network interfaces available on your system
          # and how to activate them. For more information, see interfaces(5).

          source /etc/network/interfaces.d/*

          # Loopback network interface
          auto lo
          iface lo inet loopback

          # Primary network interface
          allow-hotplug eth0
          iface eth0 inet dhcp

          # Other network interfaces
          auto eth1
          allow-hotplug eth1
          iface eth1 inet dhcp

          auto eth2
          allow-hotplug eth2
          iface eth2 inet dhcp
          post-up ip route del default
          ```

      1. Restart the network service:

          ```bash
          sudo systemctl restart networking
          ```

    {% endlist %}

1. If you previously had to remove additional network interfaces, [add](../operations/vm-control/attach-network-interface.md) them back.