All Products
Search
Document Center

Elastic Compute Service:What should I do when the error "fatal: Cannot bind any address" occurs during the SSH service startup?

Last Updated:Mar 07, 2025

This topic explains how to address the "fatal: Cannot bind any address" error encountered when you initiate the SSH service on a Linux Elastic Compute Service (ECS) instance.

Problem description

An error message stating "fatal: Cannot bind any address" appears in the command line or Secure log when you try to start the SSH service on a Linux ECS instance.

FAILED.
fatal: Cannot bind any address.
address family must be specified before ListenAddress.

Cause

The error may be due to the AddressFamily setting in the SSH service's configuration file /etc/ssh/sshd_config being configured as inet6, and the instance does not support IPv6 or the IPv6 configuration is incorrect.

Solution

  1. Connect to the ECS instance using Virtual Network Computing (VNC).

    For more information, see Connect to an instance by using VNC.

  2. Run the following command to review the /etc/ssh/sshd_config file:

    cat /etc/ssh/sshd_config

    The output below indicates that the IPv6 protocol family is in use.

    AddressFamily inet6
    Note

    The AddressFamily parameter values are as follows:

    • inet: Uses the IPv4 protocol family, which is the default setting.

    • inet6: Uses the IPv6 protocol family.

    • any: Supports both IPv4 and IPv6 protocol families.

  3. Adjust the AddressFamily parameter.

    Important

    Make sure the AddressFamily parameter is configured before ListenAddress to take effect.

    1. Run the following command to open the /etc/ssh/sshd_config file:

      vim /etc/ssh/sshd_config
    2. Press i to switch to edit mode.

    3. Change AddressFamily to inet, or add # to comment out the line before AddressFamily, as shown below.

      # AddressFamily inet6  # Comment out this configuration
      AddressFamily inet4    # Use the IPv4 protocol family
    4. Press Esc, type :wq, and press Enter to save the changes and exit the file.

  4. Run the following command to restart the SSH service:

    systemctl restart sshd.service