connect() call fails with the error code EADDRNOTAVAIL
Issue
- Using SO_REUSEADDR in bind() systemcall with a port address of 0 the connect() systemcall may result in EADDRNOTAVAIL if a socket is still open in TIME_WAIT on the assigned port
- If using a multi homed server it may be essential to use bind() systemcall before issueing connect() to specifiy the source IP address. this may result in EADDRNOTAVAIL when calling connect() afterwards
- Using autoassigned ephemeral Ports with bind() may result in EADDRNOTAVAIL error when issueing connect()
- Why does the connect() call fail with the error code EADDRNOTAVAIL in kernels 2.6.32-279.2.1 or 2.6.18-348
- An application using the connect() call fails with an error code EADDRNOTAVAIL [99]
- The error message displayed is "Cannot assign requested address" visible from the application or an
strace
performed on the application at the time of the error - This can occurr as an application binds to a local address on any ephemeral port and creates a connection to a remote node on a particular port. After a few sockets are opened, successfully bound and connected, any further connect call fails with EADDRNOTAVAIL. This happens at random intervals. Sometimes the application is able to connect hundreds of connections, and sometimes it fails after very few. In the application, it is possible the SO_REUSEADDR socket option is set on the client sockets
Environment
- Red Hat Enterprise Linux 6.3
- Red Hat Enterprise Linux 6.4
- Kernel:
2.6.32-279.2.1.el6
- Red Hat Enterprise Linux 5.9
- Kernel:
2.6.18-348.el5
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.