How Do You Troubleshoot the openssl Error “getaddrinfo: Servname not supported for ai_socktype”?

Problem scenario
You use the openssl command, but you receive an error.  You run a command such as this:

openssl s_client -connect http://www.continualintegration.com:80

You get a message such as this:
getaddrinfo: Servname not supported for ai_socktype
connect:errno=0

What should you do to view the SSL certificates?

Solution
Run the command without the "http://".  Here is an example of the correct syntax:

openssl s_client -connect continualintegration.com:80

For Future Reference
OpenSSL uses SSL and TLS.  If you want books on the subject, you may click on one of the links below:

A Concise Guide to SSL/TLS for DevOps: 2nd Edition
Bulletproof SSL and TLS: Understanding and Deploying SSL/TLS and PKI to Secure Servers and Web Applications
Implementing SSL / TLS Using Cryptography and PKI
Network Security with OpenSSL: Cryptography for Secure Communications

Join the Conversation

1 Comment

  1. I ran into a similar situation today – deploying an app to a mac os x server, and receiving the ‘getaddrinfo’ message when I tried to access an external api. It turns out that the error occurs when the ssh session that originally launched the app is no longer active. That’s why everything works perfectly if you ssh into your server and run commands manually (or launch the server manually) – as long as you keep your ssh session alive, this error won’t occur.

Leave a comment

Your email address will not be published. Required fields are marked *