From owner-freebsd-questions@FreeBSD.ORG Tue May 1 13:31:50 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1FF9F106566B for ; Tue, 1 May 2012 13:31:50 +0000 (UTC) (envelope-from b.smeelen@ose.nl) Received: from mail.ose.nl (mail.ose.nl [212.178.134.164]) by mx1.freebsd.org (Postfix) with ESMTP id AB6148FC1B for ; Tue, 1 May 2012 13:31:49 +0000 (UTC) X-Footer: b3NlLm5s Received: from localhost ([127.0.0.1]) by mail.ose.nl (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for freebsd-questions@freebsd.org; Tue, 1 May 2012 15:21:38 +0200 Message-ID: <4F9FE362.6000402@ose.nl> Date: Tue, 01 May 2012 15:21:38 +0200 From: Bas Smeelen User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120411 Thunderbird/11.0.1 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <1335866914.5649.YahooMailNeo@web160106.mail.bf1.yahoo.com> <4F9FC2AD.30905@FreeBSD.org> In-Reply-To: <4F9FC2AD.30905@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: localhost not recognised in getaddrinfo(3) in FreeBSD 9.0-STABLE X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 13:31:50 -0000 On 05/01/2012 01:02 PM, Matthew Seaman wrote: > On 01/05/2012 11:08, Unga wrote: >> Following code fragment works in FreeBSD 8.1-RELEASE, but not in FreeBSD 9.0-STABLE: >> >> error = getaddrinfo("localhost", port,&hints,&res0); >> if (error) >> { >> fprintf(stderr,"getaddrinfo failed - %s\n", gai_strerror(error)); >> exit(1); >> } >> >> It complains: getaddrinfo failed - hostname nor servname provided, or not known >> >> Any idea why? >> > So, what is the variable 'port' initialized to? It should be a const > char* with the name of a network service found in /etc/services or else > the string representation of a port number in decimal. > > Failing that, this is almost certainly a configuration snafu on your > 9.0-STABLE box. > > Does this machine have an entry for localhost in /etc/hosts ? Can it > resolve localhost via the DNS? Or through any other means such as NIS or > LDAP? > > What does: > > % getent hosts localhost > > return? > > If that fails, sanity check /etc/nsswitch.conf and /etc/resolv.conf > > Cheers, > > Matthew > Hi While updating 9.0-RELEASE to 9-STABLE today mergemaster wanted to put in a new hosts file that does not contain the localhost entry. I don know why this changed, but I left the localhost entry in my hosts file. Cheers Disclaimer: http://www.ose.nl/email