Cyroq
Posts: 50
Joined: Sat Dec 14, 2013 2:40 pm

Connection refused on apache

Tue Oct 27, 2015 8:41 pm

Hi all,

I'm running an Apache server on my Raspberry Pi, which I have installed a few months ago with my basic knowledge of Apache. I could access html and php files that were stored in /var/www from within my local network via the pi's IP address. This week, all of the blue I get a 'connection refused' error. I have no idea what happened or what could have caused this since I didn't make any changes to the network or Apache.
I have a feeling this is a permission issue. Who can help me?

User avatar
DougieLawson
Posts: 33003
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Connection refused on apache

Tue Oct 27, 2015 9:01 pm

If you suspect a permissions issue
sudo -i
cd /var/
chown -R www-data.www-data www
/etc/init.d/apache2 stop
/etc/init.d/apache2 start
exit


If that doesn't work take a look at /var/log/apache/error.log
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Cyroq
Posts: 50
Joined: Sat Dec 14, 2013 2:40 pm

Re: Connection refused on apache

Tue Oct 27, 2015 9:06 pm

Thanks for the quick reply!
It seems that the problem lies somewhere else. At step "/etc/init.d/apache2 stop" I get the response "No such file or directory". I can ftp to my Pi and I do see the file.
The log file doesn't show anything since the problem arised (the last log was from before then).

User avatar
DougieLawson
Posts: 33003
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Connection refused on apache

Tue Oct 27, 2015 9:30 pm

What OS are you running? Because it doesn't appear to be Raspbian.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Cyroq
Posts: 50
Joined: Sat Dec 14, 2013 2:40 pm

Re: Connection refused on apache

Tue Oct 27, 2015 9:37 pm

I was thinking it was Raspbian but I'm in doubt, so I tried to install lsb-release. However, that doesn't seem to work...

Code: Select all

[email protected] ~ $ sudo apt-get install lsb-release
E: Could not open lock file /var/lib/dpkg/lock - open (2: No such file or directory)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
So the problem not only Apache, it seems.

User avatar
DougieLawson
Posts: 33003
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Connection refused on apache

Tue Oct 27, 2015 9:46 pm

What happens if you reboot?
Have you got a backup SDCard in case it doesn't restart?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Cyroq
Posts: 50
Joined: Sat Dec 14, 2013 2:40 pm

Re: Connection refused on apache

Wed Oct 28, 2015 3:30 pm

If I reboot, nothing changes. The pi boots normally (as far as I can see, I don't have a monitor plugged in to it) and I can still access the files via ftp. My connection to its IP address is still refused though.

User avatar
DougieLawson
Posts: 33003
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Connection refused on apache

Wed Oct 28, 2015 3:41 pm

Can you log in with PuTTY?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
dasmanul
Posts: 501
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: Connection refused on apache

Wed Oct 28, 2015 3:53 pm

There seem to be some files missing, my guess would be an 'rm' gone wrong sometime in the past. Can you post the output of

Code: Select all

df -h
ls -l /
ls /etc
ls /etc/init.d
ls /var
ls /var/lib
ls /var/lib/dpkg

Cyroq
Posts: 50
Joined: Sat Dec 14, 2013 2:40 pm

Re: Connection refused on apache

Wed Oct 28, 2015 4:03 pm

Code: Select all

[email protected] ~ $ df -h
Filesystem                                       Size  Used Avail Use% Mounted o                                                                               n
rootfs                                           2.9G  2.7G   93M  97% /
/dev/root                                        2.9G  2.7G   93M  97% /
devtmpfs                                          56M     0   56M   0% /dev
tmpfs                                             13M  216K   12M   2% /run
tmpfs                                            5.0M     0  5.0M   0% /run/lock
tmpfs                                             25M     0   25M   0% /run/shm
/dev/mmcblk0p1                                    56M   13M   44M  23% /boot
//192.168.1.33/Media/Seagate Expansion Dr/Media  171M  552K  170M   1% /media/ne                                                                               tworkshare

[email protected] ~ $ ls -l /
total 88
drwxr-xr-x   2 root root  4096 Dec 24  2014 bin
drwxr-xr-x   5 root root 16384 Jan  1  1970 boot
drwxr-xr-x  12 root root  3120 Oct 28 15:17 dev
drwxr-xr-x 111 root root  4096 Oct 28 15:17 etc
drwxr-xr-x   3 root root  4096 Dec 21  2014 home
drwxr-xr-x  12 root root  4096 Dec 21  2014 lib
drwx------   4 root root 16384 Dec 21  2014 lost+found
drwxr-xr-x   3 root root  4096 May 23 10:22 media
drwxr-xr-x   2 root root  4096 Jul 27  2014 mnt
drwxr-xr-x   6 root root  4096 Dec 24  2014 opt
dr-xr-xr-x  85 root root     0 Jan  1  1970 proc
drwx------   2 root root  4096 Oct 27 22:38 root
drwxr-xr-x  11 root root   560 Oct 28 16:26 run
drwxr-xr-x   2 root root  4096 Dec 21  2014 sbin
drwxr-xr-x   2 root root  4096 Jun 20  2012 selinux
drwxr-xr-x   2 root root  4096 Dec 21  2014 srv
dr-xr-xr-x  12 root root     0 Jan  1  1970 sys
drwxrwxrwt   4 root root  4096 Oct 28 17:00 tmp
drwxr-xr-x  10 root root  4096 Dec 21  2014 usr
drwxr-xr-x  11 root root  4096 Oct 10 21:17 var

[email protected] ~ $ ls /etc
adduser.conf            init             profile
aliases                 init.d           profile.d
aliases.db              initramfs-tools  protocols
alternatives            inittab          pulse
apache2                 inputrc          python
apm                     insserv          python2.6
apparmor.d              insserv.conf     python2.7
apt                     insserv.conf.d   python3
avahi                   iproute2         python3.2
bash.bashrc             issue            rc0.d
bash_completion         issue.net        rc1.d
bash_completion.d       issue.net.orig   rc2.d
bindresvport.blacklist  issue.orig       rc3.d
ca-certificates         kbd              rc4.d
ca-certificates.conf    kernel           rc5.d
calendar                ldap             rc6.d
ConsoleKit              ld.so.cache      rc.local
console-setup           ld.so.conf       rcS.d
cron.d                  ld.so.conf.d     request-key.d
cron.daily              ld.so.preload    resolvconf
cron.hourly             libaudit.conf    resolv.conf
cron.monthly            libnl-3          rmt
crontab                 libpaper.d       rpc
cron.weekly             lightdm          rpi-issue
dbus-1                  locale.alias     rsyslog.conf
debconf.conf            locale.gen       rsyslog.d
debian_version          localtime        samba
default                 logcheck         securetty
deluser.conf            login.defs       security
dhcp                    logrotate.conf   selinux
dhcp3                   logrotate.d      services
dictionaries-common     magic            sgml
dillo                   magic.mime       shadow
dphys-swapfile          mailcap          shadow-
dpkg                    mailcap.order    shells
drirc                   manpath.config   skel
emacs                   menu             ssh
environment             menu-methods     ssl
esound                  mime.types       staff-group-for-usr-local
fake-hwclock.data       mke2fs.conf      sudoers
fb.modes                modprobe.d       sudoers.d
fonts                   modules          sudoers.save
fstab                   motd             sysctl.conf
fstab.d                 motd.tail        sysctl.d
fstab.save              mtab             systemd
fstab.save.1            nanorc           terminfo
fuse.conf               netconfig        timezone
gai.conf                network          timidity
gconf                   networks         transmission-daemon
gdb                     nsswitch.conf    triggerhappy
ghostscript             ntp.conf         ts.conf
gnome                   openal           ucf.conf
groff                   opt              udev
group                   os-release       ufw
group-                  os-release.orig  vim
gshadow                 pam.conf         weaved
gshadow-                pam.d            webiopi
gssapi_mech.conf        papersize        weston
gtk-2.0                 passwd           wgetrc
gtk-3.0                 passwd-          wildmidi
host.conf               perl             wpa_supplicant
hostname                php5             X11
hosts                   plymouth         xdg
hosts.allow             pm               xml
hosts.deny              polkit-1         xpdf
idmapd.conf             postfix
ifplugd                 ppp

[email protected] ~ $ ls /etc/init.d
alsa-utils              lightdm                reboot
apache2                 minissdpd              rmnologin
bootlogs                motd                   rpcbind
bootmisc.sh             mountall-bootclean.sh  rsync
cgroup-bin              mountall.sh            rsyslog
checkfs.sh              mountdevsubfs.sh       sendsigs
checkroot-bootclean.sh  mountkernfs.sh         single
checkroot.sh            mountnfs-bootclean.sh  skeleton
console-setup           mountnfs.sh            ssh
cron                    mtab.sh                sudo
dbus                    networking             transmission-daemon
dphys-swapfile          nfs-common             triggerhappy
fake-hwclock            ntp                    udev
halt                    plymouth               udev-mtab
hostname.sh             plymouth-log           umountfs
hwclock.sh              postfix                umountnfs.sh
ifplugd                 procps                 umountroot
kbd                     rc                     urandom
keyboard-setup          rc.local               webiopi
killprocs               rcS                    x11-common
kmod                    README

[email protected] ~ $ ls /var
baakups  cache  lib  locan  lock  log  mail  opt  run  spool  swap  tmp  www

[email protected] ~ $ ls /var/lib
postfix  transmission-daemon

[email protected] ~ $ ls /var/lib/dpkg
ls: cannot access /var/lib/dpkg: No such file or directory

User avatar
dasmanul
Posts: 501
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: Connection refused on apache

Wed Oct 28, 2015 4:45 pm

Assuming you're actually running Raspbian, that doesn't look too good. /var/lib/dpkg is - AFAIK- where the Debian package systems keeps all of its state information. You could try following the instructions in this post on askubuntu to restore it.

Is that really 'baakups' in /var? Should be 'backups'.

Also, I notice your root fs (which also contains /var) is quite full. It's possible that some things are missing because it was completely full at some time and they could not be properly written.

What are the contents of your /etc/os-release?

Cyroq
Posts: 50
Joined: Sat Dec 14, 2013 2:40 pm

Re: Connection refused on apache

Fri Oct 30, 2015 7:16 pm

Oh dear I don't know what happened but apparently it's not good. I had some trouble with the power supply earlier, could this possibly cause missing folders and files?

The folder is really called 'baakups', no idea how this happened. Should I change it to 'backups'?
How can I find out which folders are taking up much space? Maybe a sweep helps.
I can see os-release in the /etc folder, but when I try to access it I get a 'Not a directory'. There is a os-release.orig folder but that also results in a no directory alert.

I'm beginning to think it's a wonder it's still alive :roll: I'll look into the dpkg thread.

User avatar
dasmanul
Posts: 501
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: Connection refused on apache

Sat Oct 31, 2015 11:48 am

/etc/os-release is a text file, it's not supposed to be a folder. You can look at its contents with 'cat /etc/os-release'.

What is in you /var/baakups/ directory? On one of my Pi's, it looks like this:

Code: Select all

[email protected]:~$ ls /var/backups/
apt.extended_states.0     apt.extended_states.4.gz  dpkg.status.1.gz  dpkg.status.5.gz  passwd.bak
apt.extended_states.1.gz  apt.extended_states.5.gz  dpkg.status.2.gz  dpkg.status.6.gz  shadow.bak
apt.extended_states.2.gz  apt.extended_states.6.gz  dpkg.status.3.gz  group.bak
apt.extended_states.3.gz  dpkg.status.0             dpkg.status.4.gz  gshadow.bak
If yours looks anything similar, renaming it to backups and following the guide I linked to might be worth a try.

Cyroq
Posts: 50
Joined: Sat Dec 14, 2013 2:40 pm

Re: Connection refused on apache

Sun Nov 01, 2015 11:48 am

Thanks for your help. This is os-release:

Code: Select all

PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
NAME="Raspbian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=raspbian
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
And this is baakups:

Code: Select all

apt.extended_states.0     dpkg.status.1.gz  gshadow.bak
apt.extended_states.1.gz  dpkg.status.2.gz  passwd.bak
dpkg.status.0             group.bak         shadow.bak
I followed the guide you linkes, but at step 2 I already encounter issues:

Code: Select all

 apt-get download dpkg
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (2: No such file or directory)
E: Can't find a source to download version '1.16.15+rpi1' of 'dpkg:armhf'
My guess is too many folders have disappeared, for unexplicable reasons. I think I'd just set up the whole system again (Transmissions, Apache and WiringPi). Takes some time to figure it out again but it's probably easier than recovering all missing files without knowing what caused the problem in the first place.

Return to “Troubleshooting”

Who is online

Users browsing this forum: No registered users and 84 guests