Red Hat Enterprise Linux 5 (RHEL 5) - Error: Bind to port 22 on 0.0.0.0 failed: Address already in use
SSH connection not established. Below errors thrown in /var/log/secure.
Dec 31 10:24:54 server007 sshd: Server listening on :: port 22
Dec 31 10:24:54 server007 sshd: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
SSH is starting, the first line is it starting and binding to port 22 on ::.
Since it already has started, the second line where it tries to bind again to port 22 on 0.0.0.0 fails.
The reason is that IPv6 and IPv4 are both enabled. SSH starts and binds on port 22 to all available IPv6 IPs (::).
Then, it also tries to bind to all IPv4 IPs (0.0.0.0) in case IPv6 is disabled, but the port is already bound.
To get rid of the error message is to add a ListenAddress line into /etc/ssh/sshd_config.
For example, if only SSH listening is wanted on the internal LAN, add "ListenAddress 192.168.0.1"
<snip> #Port 22 #Protocol 2,1 Protocol 2 #AddressFamily any #ListenAddress 0.0.0.0 ListenAddress 192.168.0.1 <snip> eth0 Link encap:Ethernet HWaddr D4:85:64:4B:49:00 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fb70::f595:37bb:234b:4934/64 Scope:Link < ------- This shows that IPV6 is enabled. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2261 errors:0 dropped:0 overruns:0 frame:0 TX packets:3647 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:152291 (148.7 KiB) TX bytes:868672 (848.3 KiB) Interrupt:219
Disable IPV6 and reboot the system to resolve this issue.
Prefer to troubleshoot on your own?
Country: United States