• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Bind to port 22 on 0.0.0.0 failed: address already in use – error while starting sshd service CentOS/RHEL

by admin

The Problem

Following messages are logged when restarting sshd service in a CentOS/RHEL 5/6 system.

Dec 14 00:15:19 geeklab sshd[9182]: Received signal 15; terminating.
Dec 14 00:15:19 geeklab sshd[9274]: Server listening on :: port 22.
Dec 14 00:15:19 geeklab sshd[9274]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.

The Solution

When IPv6 and IPv4 both are enabled simultaneously, IPv6 first binds on port 22 to all available IPv6 IPs (::) when sshd service is started. So when IPv4 IPs (0.0.0.0) try to bind on the same port, the system would log the above error message. That’s because the port is already being used by IPv6 IPs.

You can check the same thing in the netstat output as well.

# netstat -anp | grep sshd
tcp        0      0 :::22                       :::*                        LISTEN      9302/sshd 

In order to resolve the issue, follow the steps outlined below:

1. Edit the sshd configuration file /etc/ssh/sshd_config and uncomment the below given line:

# vi /etc/ssh/sshd_config
ListenAddress 0.0.0.0

2. Restart the sshd service again for the changes to take effect.

# service sshd restart

3. Logs similar to below should be logged in /var/log/messages file.

Dec 14 00:35:23 geeklab sshd[9274]: Received signal 15; terminating.
Dec 14 00:35:23 geeklab sshd[9301]: Server listening on 0.0.0.0 port 22.

4. You may also check the netstat command output to confirm if sshd port 22 is listening to IPv4 Addresses only.

# netstat -anp | grep sshd
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      8977/sshd

Filed Under: CentOS/RHEL, CentOS/RHEL 5, CentOS/RHEL 6, Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 7 : systemctl replacements of legacy commands service and chkconfig
  2. How to Update the hostname in Shell Prompt Once it is Changed in the Linux OS
  3. lolcat: command not found
  4. CentOS / RHEL : How to Recover from deleted /etc/passwd file
  5. What are DNS Nameserver Types in Linux
  6. How to Setup VNC Server for New User in CentOS/RHEL 5
  7. How To Disable Weak Cipher And Insecure HMAC Algorithms in SSH services for CentOS/RHEL 6 and 7
  8. How to effectively use Man Pages under Linux
  9. How To Disable Or Extend System Logging Rate-limit on CentOS/RHEL 6
  10. After Reboot RAID1 Disk Gets Removed/Out of Sync (CentOS/RHEL)

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright