Error: Servname not supported for ai_socktype

Have you ever seen this error before? “Error: Servname not supported for ai_socktype” Well I haven’t seen it until a few days ago, when I have started working on a new server that was heavily customized by the previous sysadmin. The first thing that I wanted to do was to setup the clock properly (as it was completely wrong… not even the day was correct). Also I wanted to setup ntp to keep it synchronized properly. Since it had the ntp package already installed I have quickly launched the command:


and instead of the expected result, I got:

Error : Servname not supported for ai_socktype
4 Sep 03:25:02 ntpdate[27310]: can't find host

Hmm… Strange… DNS was working on the system, but anyway my first thought after seeing “can’t find host” was that there is some dns issue. Running:


and I got a bunch of IPs for the hostname. After this I have tried again the ntpdate command with an IP this time:

Error : Servname not supported for ai_socktype
4 Sep 03:25:49 ntpdate[27474]: can't find host

Hmm… Now what? So this is not caused by dns after all… what could this mean: “Servname not supported for ai_socktype". After some other tries I have finaly seen the problem… NTP ports were not defined in /etc/services and this was the root of the error. The system didn’t know how to make ntp connections without that. So I’ve added the following lines to /etc/services

ntp             123/tcp
ntp             123/udp

and after this ntpdate started working as expected…

3 Sep 13:25:23 ntpdate[30115]: step time server offset -50922.751623 sec

Hopefully this little story will help others seeing similar errors (Servname not supported for ai_socktype) even if this is not related to ntp, but to other application… The conclusion of this post is to check if you have the application ports defined in /etc/services if you encounter such an error… For example if whois is not working for you and giving a similar error check your services file for port 43/tcp/upd definition, etc.

comments powered by Disqus