Avatar of ccfcfc
ccfcfc
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Unable to Connect to web Site - running apache server - curl and wget returns postive results

Running Apache 2.4.12 on Ubuntu. If issue a telnet 127.0.0.1 80 all seems to be running.
If I issue " curl 127.0.0.1 example.com   and wget 127.0.0.1 example   all seems to be running. But, if on my client laptop put an entry in the host file pointing to to Linux server and a domain  e.g. 192.168.1.50 example.com   from a browser if I enter  http://example.com    the browser returns "Unable to connect"  
I have turned the firewall off using "ufw disable"  still no change. I can ping example.com from client as it responds as expected.

See output below from telnet to 127.0.0.1 80 and issuing  GET /HTTP 1.1 and curl 127.0.0.1 example.com


Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET / HTTP 1.1

HTTP/1.1 404 Not Found
Date: Tue, 26 Jan 2016 22:06:57 GMT
Server: Apache/2.4.12 (Ubuntu)
Content-Length: 276
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL / was not found on this server.</p>
<hr>
<address>Apache/2.4.12 (Ubuntu) Server at GisRoad.home Port 80</address>
</body></html>
Connection closed by foreign host.
pauls@GisRoad:~$



pauls@GisRoad:~$ curl 127.0.0.1 example.com
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL / was not found on this server.</p>
<hr>
<address>Apache/2.4.12 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>
<html>
  <head>
    <title>Welcome to Example.com!</title>
  </head>
  <body>
    <h1>Success!  The example.com virtual host is working!</h1>
  </body>
</html>
Active DirectoryApache Web ServerLinux

Avatar of undefined
Last Comment
ccfcfc

8/22/2022 - Mon
Dave Baldwin

'127.0.0.1' is always 'localhost' which refers to the computer you are on.  It is never the remote computer.  You need to use the IP address of the remote computer to get to the web server.  Use...

telnet 192.168.1.50:80

However... telnet does not speak HTTP so you are not likely to get a usable response.  curl and wget do speak HTTP.

http://curl.haxx.se/docs/manual.html
https://www.gnu.org/software/wget/manual/wget.html#Invoking
ASKER CERTIFIED SOLUTION
Andy S

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ccfcfc

ASKER
Do you mean the /etc/apache2/sites-enabled/example.com.conf ?
ccfcfc

ASKER
Dave, my output proves that apache is working hence my output using telnet and curl and wget ..it is when I use telnet 192.168.1.50 80 - - says could not open conenction to the host, on port 80  from a CMD window on my client machine. I have disabled the firewall so when I get the status it returns . See below. So I am pretty sure its not the firewall stopping it on the Linux server.

pauls@GisRoad:~$ sudo ufw status
Status: inactive
pauls@GisRoad:~$
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Dave Baldwin

You can not get to a remote server using 127.0.0.1.  That only gets to your local machine.
https://en.wikipedia.org/wiki/Localhost
ccfcfc

ASKER
Andy,
Thanks I had to add that line into the ports.conf  under /etc/apache2

Under Listen 127.0.0.1:80 I added  192.168.1.50:80 as you suggested

Thanks