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
Connect to the ECS instance using Virtual Network Computing (VNC).
For more information, see Connect to an instance by using VNC.
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
NoteThe 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.
Adjust the AddressFamily parameter.
ImportantMake sure the AddressFamily parameter is configured before ListenAddress to take effect.
Run the following command to open the
/etc/ssh/sshd_config
file:vim /etc/ssh/sshd_config
Press
i
to switch to edit mode.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
Press
Esc
, type:wq
, and pressEnter
to save the changes and exit the file.
Run the following command to restart the SSH service:
systemctl restart sshd.service