User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Pi Web Server

Tue Feb 02, 2016 10:02 pm

Just did an apt-get update && upgrade and suddenly my pi webserver is not working! Yes, I restarted the apache2 service. Any ideas? http://www.albertapi.ca is where it is supposed to be...
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
jescayola
Posts: 2
Joined: Mon Jan 25, 2016 7:55 am

Re: Pi Web Server

Tue Feb 02, 2016 11:22 pm

Is the service running? The port 80 open? the IP the same within your LAN?

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Tue Feb 02, 2016 11:26 pm

Yes to all your questions... I think.
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Wed Feb 03, 2016 1:09 am

Can you tell me how to test the first two of those states please? I have checked the IP address which hasn't changed.
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Re: Pi Web Server

Wed Feb 03, 2016 11:06 am

Check your router to see what iP address it is forwarding port 80 traffic to.

Ping your pi using the name not the iP address. It will tell you the iP address where the pi is found. Does the iP address match the one from the router?

Also check your domain's DNS settings to see what outside iP address is assigned. Visit http://www.whatsmyip.org. Does the iP address shown match the one from your DNS settings?

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi Web Server

Wed Feb 03, 2016 11:11 am

Check the network
ifconfig
ip route
ping -c3 $(ip route | awk '/default/ {print $3}')
ping -c3 8.8.8.8
ping -c3 google.com


Check the server is running
sudo netstat -tlnp

Try connecting to it
cd /tmp;wget http://localhost
Browse it locally http://192.168.xxx.xxx from your laptop.

Check your router has the right IP address (from the ifconfig) for port forwarding
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Wed Feb 03, 2016 5:39 pm

Thanks for the excellent suggestions but still no luck.
Port 80 is set to Apache2, port 3306 is mysqld and 22 is sshd. The IP address is 68.148.183.154
cd /tmp;wget http://localhost was able to connect.
But after trying all of your suggestions I still get "network unavailable"
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi Web Server

Wed Feb 03, 2016 5:55 pm

Post the results from sudo netstat -tlnp
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Thu Feb 04, 2016 1:04 am

I have been working on this all day (aaarg!). I have swapped out my old R-pi with an brand new R-pi and did a fresh install of apache2, PHP and MYSQL to no avail as the problem persists. the problem may be in my router.
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi Web Server

Thu Feb 04, 2016 9:44 am

If you can't be bothered to post the output from the diagnostic commands on here, I can't be bothered to help you.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Pi Web Server

Thu Feb 04, 2016 11:02 am

oldschool wrote:The IP address is 68.148.183.154
No it isn't. That's your external IP address. Nobody has asked for that and it doesn't matter. None of your configuration should even mention that address except perhaps the bit of Apache that checks that the correct address is being used. What has been asked for is the address of the Pi on your internal network.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Thu Feb 04, 2016 4:54 pm

I misunderstood, I thought you were simply pointing me to tools, here are the results of the tests.

IFCONFIG:

eth0 Link encap:Ethernet HWaddr b8:27:eb:93:ef:6f
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fe93:ef6f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:43 errors:0 dropped:0 overruns:0 frame:0
TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4261 (4.1 KiB) TX bytes:12892 (12.5 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)


IP ROUTE:

default via 192.168.1.1 dev eth0 metric 202
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.101 metric 202

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 938/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 489/sshd
tcp6 0 0 :::80 :::* LISTEN 752/apache2
tcp6 0 0 :::22 :::* LISTEN 489/sshd

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=47 time=51.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=47 time=62.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=47 time=50.9 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 50.930/55.009/62.597/5.370 ms

PING IP ROUTE:

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.492 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.399 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.440 ms

--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.399/0.443/0.492/0.045 ms


PING google.com (74.125.69.113) 56(84) bytes of data.
64 bytes from iq-in-f113.1e100.net (74.125.69.113): icmp_seq=1 ttl=46 time=50.9 ms
64 bytes from iq-in-f113.1e100.net (74.125.69.113): icmp_seq=2 ttl=46 time=53.1 ms
64 bytes from iq-in-f113.1e100.net (74.125.69.113): icmp_seq=3 ttl=46 time=50.7 ms

--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 50.729/51.610/53.154/1.125 ms
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Pi Web Server

Thu Feb 04, 2016 5:47 pm

That all looks normal.

Is your router set to forward incoming port 80 to 192.168.1.101 ?

I'm just wondering if your Pi's IP address has changed and that is why you can't connect in from outside.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi Web Server

Thu Feb 04, 2016 6:01 pm

Good news, your network is alive and working and you can reach the public internet.
Is your public address still 68.148.183.154
Your Raspberry currently has a LAN address of 192.168.1.101

Is your router forwarding 68.148.183.154:80 to 192.168.1.101:80

Is your webserver listening on 192.168.1.101:80? Try it with http://192.168.1.101
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Thu Feb 04, 2016 7:20 pm

Excellent, thank you very much! I wonder how my IP address changed all of a sudden? Is there a way to stop it from changing?
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Pi Web Server

Thu Feb 04, 2016 7:27 pm

oldschool wrote:Excellent, thank you very much! I wonder how my IP address changed all of a sudden? Is there a way to stop it from changing?
That's up to your router, usually.

You may be able to specify a fixed IP for the Pi, based on its MAC address, in the router config. This is the preferred option.

Or you could set the Pi to use a Static (fixed) IP that is outside the range that your router offers in its DHCP configuration, but that way lies dragons... it is possible, with a little work.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Thu Feb 04, 2016 7:57 pm

All good, I found a tutorial on setting a static IP so, with any luck, I can get back to learning PHP and MySQL for websites on my Pi. Thanks for all your help!!!
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Pi Web Server

Thu Feb 04, 2016 8:02 pm

oldschool wrote:All good, I found a tutorial on setting a static IP so, with any luck, I can get back to learning PHP and MySQL for websites on my Pi. Thanks for all your help!!!
Make sure it's an up to date tutorial.

There is an old way of setting a static address by editing /etc/network/interfaces, and a new way by editing /etc/dhcpcd.conf. The old way works on Raspbian Wheezy and the new way works on Raspbian Jessie.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Thu Feb 04, 2016 8:33 pm

I do not seem to have a /etc/dhcpcd.conf file. Does that mean I am ok using the etc/network/interfaces method?
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi Web Server

Thu Feb 04, 2016 9:39 pm

Take a look at /etc/os-release that will tell you whether you're running Wheezy (V7) or Jessie (V8).
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Thu Feb 04, 2016 10:38 pm

Yes, I am definitely using Jessie (V8) and I have found dhcpcd.conf so now all I need to do is find out what to put in there. Very confusing - I think you are right: "there be dragons".
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Pi Web Server

Fri Feb 05, 2016 8:44 pm

rpdom wrote:There is an old way of setting a static address by editing /etc/network/interfaces, and a new way by editing /etc/dhcpcd.conf.
... and there is yet another one on the way: systemd-networkd.service. It's already shipped with Jessie but disabled:

Code: Select all

# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
   Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled)
   Active: inactive (dead)
     Docs: man:systemd-networkd.service(8)
It's disabled but the man pages and config files are waiting for you to play with it. You are just a # systemctl enable systemd-networkd away from it.

Nice wiki here:
https://wiki.archlinux.org/index.php/systemd-networkd
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Sat Feb 06, 2016 12:23 am

I am going to come across as being thick but the Wiki doesn’t seem to be in a language I understand.  I am a rank amateur not trained in system level software. Is it possible to give me step by step instructions at kindergarten level please?
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Pi Web Server

Sat Feb 06, 2016 7:15 am

oldschool wrote:Is it possible to give me step by step instructions at kindergarten level please?
Yes it's easy for me, I am not a native english speaker. So here it is, in my best pigeon english:

In your case, the best way to get a fix IP address for your pi is to keep dhcpcd.conf as it is by default. It will keep on requesting an IP address from your main router. Why is that? Because if, one day, you decide to change your network topology, or if you want to take your pi to a friend to show your web site, if he has another network topology, you may risk not being able to connect to it anymore.

Now the router. Most of the routers out there can reserve the same IP address for your pi. You only have to tell him that when it sees a request coming from the pi to give it the same ip over and over again. No other device on the network will ever get that ip. How can your router identify the IP request from the pi? Simply by looking at it's unique identifier, the MAC address which seems to be b8:27:eb:93:ef:6f. In your browser, connect to your router (http://192.168.1.1) and find the option concerning the static/reserved/fixed IP in the menus. Put there the MAC of the pi and the IP you want to give to it, save the new router setup, restart the pi and you are done.

Now just a side note, do you really need Apache as web server? It's a kind of a monster compared to the lightweight web servers like lighttpd or, to a lesser extend, nginx. http://wiki.dreamhost.com/Web_Server_Pe ... Comparison
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

User avatar
oldschool
Posts: 26
Joined: Sun Apr 28, 2013 6:32 pm
Location: Edmonton, Alberta, Canada
Contact: Website

Re: Pi Web Server

Wed Feb 10, 2016 9:00 pm

So tell me why I still can’t access my website www.albertapi.ca (192.168.1.101) from the outside world please? I can get to the site from my PC workstation, my cell phone (when I am home) and my daughter’s laptop (when at home) but if I leave home or have someone else try from a distant location they can’t get in. I have the albertapi.ca DNS at godaddy.com set to 192.168.1.101 and I think I have t static now (finally - thank you!). What am I misunderstanding please?
Tim
raspi@shaw.ca
www.cad272.ca
Outside of a dog, a book is man’s best friend. Inside of a dog it’s too dark to read.

Return to “Troubleshooting”