Working around ddclient’s “bad hostname” and “network is unreachable” problems

I have had continuing problems with ddclient being able to connect to the network and make an http call to check my current IP address. If you use ddclient and also see this problem, this workaround might work for you, too.

The ddclient bug exhibits itself with two errors I would see in the system log and also kindly emailed to me by the ddclient daemon itself:
WARNING:  cannot connect to socket: IO::Socket::INET: Bad hostname ''
or the more generic error:
WARNING:  cannot connect to socket: IO::Socket::INET: connect: Network is unreachable
The issue seems to be that ddclient, a Perl client that talks to dynamic DNS services like, has problems either making network connections or perhaps caches a bad address at system start when networking services might not yet be up. This problem with ddclient seems longstanding, with a bug filed in 2003 on the Debian list and a bug filed in 2009 on the Red Hat list.

The Red Hat bug was closed May 29 with a fix (ddclient- posted to update sites for Fedora 11 and later. But if you have not or cannot update, or still see the bug, here's my workaround: Instead of using ddclient's built-in web client to connect to your dynamic-DNS service, call a shell script that uses curl to make the network call. Specifically, I replaced this line in my /etc/ddclient.conf configuration file:
use=web,, web-skip='IP Address' # found after IP Address
with this line:
use=cmd, cmd=/home/tom/bin/, cmd-skip='IP Address' # found after IP Address
Here is my shell script, stored in my home "bin" directory:
# A script to fill in for what ddclient
# can't seem to do: reliably connect to
That's it. The only extra steps you need to take are to ensure the user that runs your ddclient daemon (typically user "ddclient") has access to the script. That means in my case making sure the script itself is executable, e.g. chmod 755 ~/bin/, and that my home directory and bin directory are world executable, e.g. chmod --recursive o+x ~/bin/

When I eventually upgrade my system and use version of ddclient, I look forward to seeing if this longstanding networking bug really got fixed.

One thought on “Working around ddclient’s “bad hostname” and “network is unreachable” problems

  1. I am also experiencing this error and this is the only post I’ve found to address it other than upgrading ddclient… which seems to already be the latest version in my distro. Thank you!

Comments are closed.