Saturday, March 26, 2016

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName


CentOS 5.0

http://stackoverflow.com/questions/9541460/httpd-could-not-reliably-determine-the-servers-fully-qualified-domain-name-us
I tried to restart my apache server and got this messeage
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
here is /etc/host file
127.0.0.1   server4-245 server4-245.com localhost.localdomain localhost
::1     localhost6.localdomain6 localhost6
here is /etc/sysconfig/network file
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server4-245
I also have this in apache httpd.conf file
ServerName localhost
However, I still get the first error messeage when I restart the apache.
shareimprove this question
  
Ensure you edited the right httpd.conf. Usually ServerName xy is just fine. – KingCrunch Mar 2 '12 at 22:53

8 Answers


up vote56down voteaccepted
Your hosts file does not include a valid FQDN, nor is localhost an FQDN. An FQDN must include a hostname part, as well as a domain name part. For example, the following is a valid FQDN:
host.server4-245.com
Choose an FQDN and include it both in your /etc/hosts file on both the IPv4 and IPv6 addresses you are using (in your case, localhost or 127.0.0.1), and change your ServerName in your httpd configuration to match.
/etc/hosts:
127.0.0.1    localhost.localdomain localhost host.server4-245.com
::1          localhost.localdomain localhost host.server4-245.com
httpd.conf:
ServerName host.server4-245.com
shareimprove this answer
5
Note too that you'll want to modify your HOSTNAME entry in your /etc/sysconfig/network file to match your chosen name. – Paul Stengel Mar 2 '12 at 23:55
2
Hmm. I've got: 127.0.0.1 localhost gondor gondor.localdomain 192.168.0.3 gondor.localdomainbut it seems linux doesn't think that gondor.localdomain is an FQDN either. What's the issue with that? Do I have to have a TLD? – Adam May 10 '13 at 10:08
1
in general @PaulStengel answers with example code fare better than theoretical answers.. compare the answer below with yours – abbood Apr 23 '14 at 6:14
  
@abbood: Agreed. Updated my answer to include some examples. – Paul Stengel May 9 '14 at 0:30
  
Hi I did try all of the above and I am still getting the same errors, I don't quite understand what I lack here. My FQDN is ak.local.com set in the same fashion as your answer but I am still getting the same issues. I am running on OSX 10.10 – AKFourSeven Jan 20 '15 at 18:43

if you don't have httpd.conf under /etc/apache2, you should have apache2.conf - simply add
ServerName localhost
then restart apache2 service
shareimprove this answer
2
Worked perfectly on Ubuntu 12.04 LTS running multiple virtual hosts. – Gor Jan 7 '13 at 0:43
2
Worked perfectly on Mac OS 10.7.5 running multiple virtual hosts. – DudeOnRock May 7 '13 at 0:41
1
Worked on Mac OS 10.7.5 running Virtualbox – CroiOS May 20 '13 at 13:40
3
Worked perfectly on Centos 6.4. – Kel Solaar Jul 29 '13 at 21:10
6
Worked perfectly on Centos 6 (cloud version), though httpd.conf was in /etc/httpd/conf/ – gbarry Aug 31 '13 at 23:20