bind(): Cannot assign requested address
by
, September 28, 2014 at 6:10 AM (65484 Views)
I spent 6 hours (or more, I don't know) dealing with this tonight, particularly in the antiquated DomainKeys milter for Postfix (not to be confused with the oft-confused Domain Keys/DKIM).
My /var/logs/maillog was filling up in seconds to many megabytes in size, simply repeating a variation of:
To the point where every 30 seconds I would have to truncate the log file just to avoid running out of space on the partition.Code:bind(): Cannot assign requested address
All I wanted to do was have the milter listen on port 19892. Repetitive checks to netstat and lsof showed that no processes were using the port, yet the issue persisted.
I went so far as completely rewriting the init.d script (which was hard enough to find as it was for something published in 2007), under the premise that maybe it was just initing itself too many times and engaging in a race condition with itselves.
Searched around Google and StackOverflow for hours, trying to find someone with the same problem to no avail. I just about gave up on DomainKeys and uninstalled it several times, citing that no one uses it as a sole means for email verification anyway.
At some point of reading all these other issues, discounting the ones where ports were actually unavailable, people mistyping IP addresses and such and banging my head because I was only trying to bind to localhost, and it was spelled correctly.
And then I had a eureka moment, because we had recently updated the hostname for the server, including the 127.0.0.1 address. And of course, rather than putting the new name as an alias, we inadvertently had erased localhost from the /etc/hosts file.
So of course it could not bind to localhost, because "localhost" is actually not a hard-coded shortcut, it was actually defined as 127.0.0.1 in /etc/hosts
After adding it back to the file like so:
The insanity-inducing bind() errors came to an end.Code:127.0.0.1 custom.tld localhost localhost.localdomain