Let me start by saying I'm not a sys admin but I've been tasked with creating a new apache web server. For now, I'm just trying to install the base package, confirm it's working and communicating on the network... and then try to set up the apache2-ldap module.


When I try to reach the new server from a browser on a remote machine by using it's ip address (let's say for example , I get ERR_CONNECTION_TIMED_OUT message.

How I did the Install

  1. I did an "apk add apache2". This created the default conf file and the folder / file in /var/www/localhost/htdocs/index.html
  2. Then I edited the /etc/hosts file so it looks like this:
mytestserver:/# cat /etc/hosts       localhost       webdev.<mydomainname>
  1. I edited /etc/apache2/httpd.conf and added the ServerName. These are some of the entries I have in the httpd.conf file right now:
   ServerName localhost
   DocumentRoot "/var/www/localhost/htdocs"    

   <Directory />
        Options FollowSymLinks
        AllowOverride none
    #    Require all denied
    #    Order allow,deny
    #    Deny from all

    <Directory "/var/www/localhost/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride All
    #    Require all granted
        Order allow,deny
        Allow from all
  1. Then I restarted apache and made sure it starts without any errors.

What I've Tried / Checked So Far

  1. Made sure the service is running: mytestserver:/# wget rc-status Runlevel: default iptables [ started ] networking [ started ] snmpd [ started ] sshd [ started ] apache2 [ started ]

  2. Tried to reach the server from the server itself using wget (not sure if it's a good idea but i thought it would prove that http traffic is working this server...) As you can see from the example below, it worked.

mytestserver:/# wget localhost
Connecting to localhost (
index.html           100% |********************************************************************************************************************|    45   0:00:00 ETA

I stopped apache on the server and retried the same wget test and it fails:

Connecting to localhost (
wget: can't connect to remote host ( Connection refused

Which, in my mind proves that apache itself is working on this server.

  1. Checked netstat for the port status:
mytestserver:/# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0    *               LISTEN      213/sshd
tcp        0      0 :::80                   :::*                    LISTEN      5599/httpd
tcp        0      0 :::22                   :::*                    LISTEN      213/sshd
udp        0      0   *                           2305/snmpd
Active UNIX domain sockets (only servers)
  1. As I am trying to open the browser on the remote machine, I did a tail -f on the apache error log. But nothing is showing up. Same goes for the access.log... which tells me that it's not hitting the server at all?

Not sure what else to check. I'm currently reading other posts here to see if I can find something to point me in the right direction. But if you have any tips, I'd appreciate it. Thanks.

  • 3
    What host name are you trying to connect to? Are you aware that localhost/ is always the address of a computer itself so if you try to connect to localhost on any computer, you try a connection to itself and not to some remote server...
    – Sven
    Mar 29, 2017 at 17:41
  • @Sven yes, i do realize that. i did that on purpose to see if wget would work.... thinking that would prove that apache was running. From remote machines, I'm using the iP address of the apache server. i thought that would be clear by the fact that the prompt in my samples are from the web server itself. But i will add a comment to clarify my question... and clarify the tests i'm running
    – dot
    Mar 29, 2017 at 20:43
  • If you're running an Amazon EC2 server, did you check "Allow HTTP traffic from the internet" when creating the instance? You may need to add some HTTP inbound rules
    – bobobobo
    Feb 4 at 1:24

2 Answers 2


Based on your description it sounds like you're using localhost as the server name. That's always the local computer as pointed out in the comments. You would need to 1) configure Apache to listen on a name other than localhost (it appears you were trying to use webdev), 2) add a record to your DNS server on your local network called webdev to point at the IP of mytestserver, or alternatively add a record to the HOST file pointing to the IP of that server on the test client machine (not, and 3) make sure your firewall is open to accept connections on port 80. You could also simply request the site via the network IP of the mytestserver machine (also not, check ifconfig) if that's the default site for your apache configuration.


The problem was the apache conf. Port 80 was open ... but listening on :::80
I changed the "Listen" address in the config from this:

Listen 80

to this:


And now it works. I can launch the site from the remote machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .