• 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. if Command Examples in Linux
  2. Integrate Linux Servers with Active Directory using Samba, Winbind, and Kerberos
  3. feedreader: command not found
  4. Rpm: Error While Loading Shared Libraries: Libz.so.1: Cannot Open Shared Object File: No Such File
  5. CentOS / RHEL 7 : Shutting Down, Suspending, or Rebooting Commands (systemctl)
  6. cryptsetup Command Examples in Linux
  7. How to Check Swap Usage Live via the ‘top’ Command in Linux
  8. ‘Found duplicate PV’ warnings when using LVM with multipath storage in RHEL/CentOS
  9. ispell: command not found
  10. fdisk: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright