You are not logged in.

#1 2007-01-02 04:19:05

foxbunny
Member
From: Serbia
Registered: 2006-10-31
Posts: 759
Website

Apache: "Could not connect to host localhost" erro

I have installed Apache before (on Ubuntu) and, usually, after install, I'd just go to http://localhost/ and a test page would appear... but not on Arch. smile

I routinely installed apache package, started apache by issuing "apachectl -k start", and tried to connect to localhost, but it didn't work. So I googled around for a while and tried again, this time changed a httpd.conf line to:

ServerName localhost:80

The error I'm getting is:

An error occurred while loading http://localhost/:
Could not connect to host localhost.

Is there something more I should do to get apache to start? (Well, obviously there is, or I wouldn't be here, duh!)

Offline

#2 2007-01-02 07:24:07

stonecrest
Member
From: Boulder
Registered: 2005-01-22
Posts: 1,190

Re: Apache: "Could not connect to host localhost" erro

is localhost in your /etc/hosts?


I am a gated community.

Offline

#3 2007-01-02 11:06:05

foxbunny
Member
From: Serbia
Registered: 2006-10-31
Posts: 759
Website

Re: Apache: "Could not connect to host localhost" erro

Here's the file:

#
# /etc/hosts: static lookup table for host names
#

#<ip>   <hostname>   <hostname>
127.0.0.1               localhost.localdomain   localhost

# End of file

Offline

#4 2007-01-02 12:10:41

harlekin
Member
From: Germany
Registered: 2006-07-13
Posts: 408

Re: Apache: "Could not connect to host localhost" erro

I don't know wether this causes the problem, but all /etc/hosts I saw looked a little different from yours.

As far as I know localhost has to be replaced with the value for HOSTNAME made in /etc/rc.conf. If it's localdomain too, I didn't say anything but you are the first one I've seen who hasn't changed it. (Which is nothing bad at all but caused my attention.)


Hail to the thief!

Offline

#5 2007-01-03 14:35:32

foxbunny
Member
From: Serbia
Registered: 2006-10-31
Posts: 759
Website

Re: Apache: "Could not connect to host localhost" erro

@harlekin

Thanks for the info. I was totally unaware of that.

My hostname is foxen1.

So do I change /etc/hosts to:

#<ip>   <hostname>   <hostname>
127.0.0.1               foxen1   localhost 

Or:

#<ip>   <hostname>   <hostname>
127.0.0.1               foxen1   foxen1

?

Offline

#6 2007-01-03 15:07:44

RedShift
Member
From: Belgium
Registered: 2004-07-16
Posts: 230

Re: Apache: "Could not connect to host localhost" erro

Did you
/etc/rc.d/httpd start
and what happens if you surf to
http://127.0.0.1
?


:?

Offline

#7 2007-01-03 16:19:16

harlekin
Member
From: Germany
Registered: 2006-07-13
Posts: 408

Re: Apache: "Could not connect to host localhost" erro

foxbunny wrote:

@harlekin
So do I change /etc/hosts to:

#<ip>   <hostname>   <hostname>
127.0.0.1               foxen1   localhost 

Or:

#<ip>   <hostname>   <hostname>
127.0.0.1               foxen1   foxen1

?

I think it has to be:

#<ip-address>    <hostname.domain.org>    <hostname>
127.0.0.1        foxen1.localdomain    foxen1

Hail to the thief!

Offline

#8 2007-01-03 16:19:46

STiAT
Member
From: Vienna, Austria
Registered: 2004-12-23
Posts: 606

Re: Apache: "Could not connect to host localhost" erro

/etc/hosts

127.0.0.1               localhost.localdomain   localhost

note: you can change this, i don't see any need to do so, apache runs fine like this as well.

/etc/httpd/conf/httpd.conf

Listen localhost:80

note: Listen not ServerName...

/etc/rc.conf

HOSTNAME="n501931pc"

note: that's my hostname, yours is fine wink


Ability is nothing without opportunity.

Offline

#9 2007-01-03 20:35:13

foxbunny
Member
From: Serbia
Registered: 2006-10-31
Posts: 759
Website

Re: Apache: "Could not connect to host localhost" erro

STiAT wrote:

/etc/hosts

127.0.0.1               localhost.localdomain   localhost

note: you can change this, i don't see any need to do so, apache runs fine like this as well.

Hehe, then I won't. The less I change, the easier to spot problems... smile

STiAT wrote:

/etc/httpd/conf/httpd.conf

Listen localhost:80

note: Listen not ServerName...

Okay. But the ServerName shoud be what? "localhost:80" as well?

STiAT wrote:

/etc/rc.conf

HOSTNAME="n501931pc"

note: that's my hostname, yours is fine wink

Okay, thanks. I'll go and try that out.

Offline

#10 2007-01-03 20:43:35

foxbunny
Member
From: Serbia
Registered: 2006-10-31
Posts: 759
Website

Re: Apache: "Could not connect to host localhost" erro

Okay, failing to follow my own advice (that I gave myself, too) I changed to /etc/hosts to this:

#<ip>   <hostname>   <hostname>
127.0.0.1               foxen1                             foxen1

Then I changed Listen:

Listen foxen1:80

And that didn't work. Finally, I read the commented lines in httpd.conf. (Vim's fault, not mine. Vim displays commented lines as dark blue, very hard to read on a black background.) Noticed that if my server has not valid DNS entry (and it doesn't) then I should enter my IP address. So I entered:

ServerName 127.0.0.1:80

Tadaaaa! Works. Thanks everyone for feedback!

Offline

Board footer

Powered by FluxBB