403 Forbidden using Flask, WSGI and Apache2

I’m getting 403 Forbidden when trying to access my Flask app from my local notebook using my Droplet’s IP. Any help would be appreciated!

This is my Apache2 error log:

[Thu Oct 27 08:33:22.308733 2016] [authz_core:debug] [pid 24390:tid 140263676557056] mod_authz_core.c(809): [client] AH01626: authorization result of Require all denied: denied
[Thu Oct 27 08:33:22.308770 2016] [authz_core:debug] [pid 24390:tid 140263676557056] mod_authz_core.c(809): [client] AH01626: authorization result of <RequireAny>: denied
[Thu Oct 27 08:33:22.308774 2016] [authz_core:error] [pid 24390:tid 140263676557056] [client] AH01630: client denied by server configuration: /home/mats/var/www/TVApp/tvapp.wsgi

This is my conf file:

<VirtualHost *:80>
                WSGIScriptAlias / /home/mats/var/www/TVApp/tvapp.wsgi
                <Directory /home/mats/var/www/TVApp/TVApp/>
                        Require all granted
                Alias /static /home/mats/var/www/TVApp/TVApp/static
                <Directory /home/mats/var/www/TVApp/TVApp/static/>
                        Require all granted
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel debug
                CustomLog ${APACHE_LOG_DIR}/access.log combined

My wsgi file:

import sys
import logging

from TVApp import app as application
application.secret_key = 'Add your secret key'

This is the output of apachectl -S:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80          (/etc/apache2/sites-enabled/TVApp.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
PidFile: "/var/run/apache2/"
User: name="www-data" id=33
Group: name="www-data" id=33

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I am not seeing anything in your VirtualHost configuration that should cause the error you’re seeing. I have a couple questions to try and get started debugging this:

1.) Is this the only Virtualhost defined in your configuration? Is the default one still present? It’s possible that your requests are hitting the wrong VirtualHost handler, causing errors that don’t make sense in context to the one you think is being used.

2.) Have you restarted apache after editing your virtualhost configuration?

3.) Do you get any different results if you try removing the sections related to your /static directory?