You are not logged in.

#1 2014-08-03 02:36:02

jfharper
Member
Registered: 2014-08-03
Posts: 11

[SOLVED] Can't connect to Apache Server Locally

I'm running ArchLinux on a GoFlex Home base with USB stick.  I've installed apache.  I didn't have to change anything in httpd.conf, Listen is set to 80.  In hosts, I changed 127.0.0.1 to my servers ip and added a hostname, myhostname.  I can ping myhostname and apache server ip in ssh and in windows xp command prompt I can ping server ip only...myhostname says ping request cannot find host myhostname.  In a browser I enter the server ip and I get:
Unable to connect

Firefox can't establish a connection to the server at (servers IP).

    *   The site could be temporarily unavailable or too busy. Try again in a few
          moments.

    *   If you are unable to load any pages, check your computer's network
          connection.

    *   If your computer or network is protected by a firewall or proxy, make sure
          that Firefox is permitted to access the Web.

IE same sort of message, chrome says "Google Chrome's connection attempt to (servers ip) was rejected."

Also tried from an ipad wifi connected to my home local network using safari, and said, Safari cannnot open page b/c it could not connect to the server.  Both xp computer and goflex base are wired connected to home lan running a single router.

Before I changed the 127.0.0.1 to my servers ip in hosts and added a hostname, I tried localhost in browser and got same messages above.  I tried pinging localhost and 127.0.0.1 and got a ping.  I powered the GoFlex base off, and still got a ping from 127.0.0.1, can't remember if I also got a ping from localhost with goflex powered off, I might have.  My router has a web server setting enabled...I turned it off (temp tested), but then couldn't login to the router to configure using browser like I do normally...so that setting has to stay enabled.  Do I need to do a port forward in my router to get local browser access to my apache server?  Or am I missing something simple.  This goflex base will be my internet web server in the end.

Last edited by jfharper (2014-08-04 18:17:45)

Offline

#2 2014-08-03 06:22:23

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] Can't connect to Apache Server Locally

Does 'systemctl status apache' report anything useful?

Last edited by thiagowfx (2014-08-03 06:22:32)

Offline

#3 2014-08-03 21:35:43

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

● apache.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

Offline

#4 2014-08-03 22:13:04

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [SOLVED] Can't connect to Apache Server Locally

And `systemctl status httpd`?

Offline

#5 2014-08-04 00:31:46

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] Can't connect to Apache Server Locally

Ops, sorry, I should have said 'httpd' instead of 'apache', as @Spider.007 suggested.

Offline

#6 2014-08-04 03:09:19

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

In trying some things (blindly) I changed the ip in hosts back to 127.0.0.1 and removed myhostname from the end of the top line...the browser still will not connect...here is the output of the command you requested:

● httpd.service - Apache Web Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
   Active: active (running) since Sun 2014-08-03 21:06:22 MDT; 14s ago
  Process: 553 ExecStop=/usr/bin/apachectl graceful-stop (code=exited, status=0/SUCCESS)
  Process: 560 ExecStart=/usr/bin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 563 (httpd)
   CGroup: /system.slice/httpd.service
           ├─563 /usr/bin/httpd -k start
           ├─564 /usr/bin/httpd -k start
           ├─565 /usr/bin/httpd -k start
           └─566 /usr/bin/httpd -k start

Aug 03 21:06:22 myhostname apachectl[560]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.101. Set the 'ServerName' directive globally to suppress this message
Aug 03 21:06:22 myhostname systemd[1]: PID file /run/httpd/httpd.pid not readable (yet?) after start.
Aug 03 21:06:22 myhostname systemd[1]: Started Apache Web Server.

Last edited by jfharper (2014-08-04 03:31:25)

Offline

#7 2014-08-04 03:18:14

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] Can't connect to Apache Server Locally

The output looks okay to me. What about

curl -v localhost

You can also replace localhost with your current hostname.

Also, would you mind trying with nginx or lighttpd? The Wiki has instructions about them. Just to see if they work for you. Just a warning: if you will try them, do not forget to stop the httpd (apache) systemd service first.

Offline

#8 2014-08-04 03:19:38

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

* Rebuilt URL to: localhost/
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 04 Aug 2014 03:19:07 GMT
* Server Apache/2.4.10 (Unix) is not blacklisted
< Server: Apache/2.4.10 (Unix)
< Last-Modified: Sat, 02 Aug 2014 01:29:28 GMT
< ETag: "6e-4ff9b6fd3ae00"
< Accept-Ranges: bytes
< Content-Length: 110
< Content-Type: text/html
<
<html>
  <head><title>Apache Home</title></head>
  <body><h1>Apache Server is working..!!</h1></body>
</html>
* Connection #0 to host localhost left intact

Last edited by jfharper (2014-08-04 03:31:49)

Offline

#9 2014-08-04 03:27:20

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] Can't connect to Apache Server Locally

This output clearly indicates your apache server is working. I was expecting to see something like:

* Rebuilt URL to: localhost/
* Hostname was NOT found in DNS cache
*   Trying ::1...
* connect to ::1 port 80 failed: Connection refused
*   Trying 127.0.0.1...
* connect to 127.0.0.1 port 80 failed: Connection refused
* Failed to connect to localhost port 80: Connection refused
* Closing connection 0

For comparison, here is the output of the same command with a working nginx server (wouldn't be much different for a working apache):

* About to connect() to localhost port 80 (#0)
*   Trying ::1...
* Connection refused
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.26.0
> Host: localhost
> Accept: */*
> 
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Server: nginx/1.2.1
< Date: Mon, 04 Aug 2014 03:23:06 GMT
< Content-Type: text/html
< Content-Length: 211
< Last-Modified: Sat, 02 Aug 2014 01:59:13 GMT
< Connection: keep-alive
< Accept-Ranges: bytes
< 
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!</h1></center>
</body>
</html>

I believe the problem is with your browsers (it is strange that none of them seems to work), in this case. However, I'm not sure what to suggest now. Do you have something different of localhost in /etc/hosts* (/etc/hosts and /etc/hosts.deny)? Any configured proxy in your browsers? Maybe some plug-in/add-on? Try again in incognito mode / privative browsing.

Edit: please use code tags for code output.

Last edited by thiagowfx (2014-08-04 03:28:41)

Offline

#10 2014-08-04 03:40:16

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

/etc/hosts

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

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1       localhost.localdomain   myhostname
::1             localhost.localdomain   localhost

# End of file

no /etc/hosts.deny found in /etc directory

No proxy in firefox (according to settings), none in IE, none in chrome, just did a fresh install of xp (deleted partition, created partition, format c drive, then fresh install) no plugins or addons were added.  Weird this also happens from ipad safari...I'm trying nginx as we speak and I'll try the other one...do you think it's something with my router?  I only have one, it has a Web Server setting set to port 80 that has to be enabled for me to be able to login via a browser and change settings.

I really don't know that much about networking...could it be that 127.0.0.1 is not on the same subnet as my xp computer and thus the computer won't allow the browser?  But why can I ping 127.0.0.1 with the goflex off and still get a ping?

Does the ip address in hosts (127.0.0.1) have to be changed to my servers ip?

Last edited by jfharper (2014-08-04 04:04:13)

Offline

#11 2014-08-04 04:32:06

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] Can't connect to Apache Server Locally

Just to be clear: when you said in your first post you tried with Firefox, IE and Chrome, all three were from Windows XP, right? I think I see the problem, then.

In your Arch, tell me the output of

ip addr

In the case the ip program is not installed, you can also use

ifconfig

Just one output is sufficient.

Try to find your IP in this output (it is probably 192.168.0.<some number> or 192.168.1.<some number>). Then, try to access this IP from your windows XP, ipad, etc.

Last edited by thiagowfx (2014-08-04 04:32:49)

Offline

#12 2014-08-04 12:28:46

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: [SOLVED] Can't connect to Apache Server Locally

jfharper wrote:

I'm running ArchLinux on a GoFlex Home base with USB stick.  I've installed apache.  I didn't have to change anything in httpd.conf, Listen is set to 80.  In hosts, I changed 127.0.0.1 to my servers ip and added a hostname, myhostname.  I can ping myhostname and apache server ip in ssh and in windows xp command prompt I can ping server ip only...myhostname says ping request cannot find host myhostname

Before I changed the 127.0.0.1 to my servers ip in hosts and added a hostname, I tried localhost in browser and got same messages above.  I tried pinging localhost and 127.0.0.1 and got a ping.  I powered the GoFlex base off, and still got a ping from 127.0.0.1, can't remember if I also got a ping from localhost with goflex powered off, I might have.  My router has a web server setting enabled...I turned it off (temp tested), but then couldn't login to the router to configure using browser like I do normally...so that setting has to stay enabled.  Do I need to do a port forward in my router to get local browser access to my apache server?  Or am I missing something simple.  This goflex base will be my internet web server in the end.

127.0.0.1 is the loopback address so pinging 127.0.0.1 from the Windows box was just pinging the Windows box itself etc.
Altering the 127.0.0.1 line in /etc/hosts will just confuse programs on the arch box that expect localhost to resolev to 127.0.0.1.
Adding / altering entries in /etc/hosts will not allow other machines to resolve your server by hostname you need a domain name server or manually add static entries to the hosts file of every box you want to resolve the hostname.
From the systemctrl apache status it is / was using 192.168.1.101  was that the ip address you were attempting to connect to from the Windows box?

Offline

#13 2014-08-04 17:50:34

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 02:50:43:8f:c9:8c brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.124/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::50:43ff:fe8f:c98c/64 scope link
       valid_lft forever preferred_lft forever

Offline

#14 2014-08-04 18:03:01

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

thiagowfx wrote:

Just to be clear: when you said in your first post you tried with Firefox, IE and Chrome, all three were from Windows XP, right?

Yes.

thiagowfx wrote:

Try to find your IP in this output (it is probably 192.168.0.<some number> or 192.168.1.<some number>). Then, try to access this IP from your windows XP, ipad, etc.

OH! That worked.  I feel like such a gimp.  I thought I had tried that before...maybe I didn't...my mind is sort of swimming with information.  I really just followed the guides on setting up apache and they all said to type "localhost" in your browser, or 127.0.0.1 and it should bring up the placeholder page...but when that didn't work for me, I really didn't know what to do...maybe I was over thinking it.

Great...thank you all so much for your replies...I really appreciate your help.

So, when I first followed a tutorial on YouTube, the first thing they had me do was setup a static ip by copying a file from the example folder to netctl folder I believe and name it staticip...in that file I was to set a static ip instead of the ip range and set my gateway and dns which are both 192.168.1.1.  Then in the ip addr output above, the first ip was the static AND there was a second ip dynamic both set for the eth0...I hope that is normal.  When I began having trouble, I stripped everything back to make it simple and removed the staticip file so I didn't have anything else I had done which may have contributed to the problem.

Also, the servers ip given with curl -s icanhazip.com is different than the devices ip given with ip addr...I was trying the servers ip in the browser and in hosts, but both did nothing...I didn't think the devices ip was what I was supposed to use...but it makes sense now.

Last edited by jfharper (2014-08-04 18:04:44)

Offline

#15 2014-08-04 18:17:20

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

loqs wrote:

Adding / altering entries in /etc/hosts will not allow other machines to resolve your server by hostname you need a domain name server or manually add static entries to the hosts file of every box you want to resolve the hostname.

OK...I'll try to look up this information so I can figure out what I need to do to get the rest of this setup...I kind of get what your saying but am having trouble figuring out what to do exactly.


loqs wrote:

From the systemctrl apache status it is / was using 192.168.1.101  was that the ip address you were attempting to connect to from the Windows box?

nope...that was my trouble...I was trying everything but.

Offline

#16 2014-08-04 19:09:11

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] Can't connect to Apache Server Locally

Glad to hear it worked out for you! However, your IP changed from 192.168.1.101 from your first post to 192.168.1.124 in your last one; it will probably keep changing. So, if you plan to frequently access your Arch machine from other devices, you should assign a static IP to it -- this is usually done in your router DHCP settings.

Offline

#17 2014-08-04 19:32:28

jfharper
Member
Registered: 2014-08-03
Posts: 11

Re: [SOLVED] Can't connect to Apache Server Locally

Right...I got that...thanks though! wink

Offline

Board footer

Powered by FluxBB