Question

403 Forbidden error in django app hosting on apache

Posted July 4, 2020 4.2k views
ApacheDjangoDatabases

firstly i was facing this error
operatonal error randomly database write

but when i fixed this error by these commands
chmod 664 ~/myproject/db.sqlite3
sudo chown :www-data ~/myproject/db.sqlite3
sudo chown :www-data ~/myproject

then i got this error
Forbidden
You don’t have permission to access this resource.

please help me

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.

×
Submit an Answer
1 answer

Hi @akshaykoshti401,

Apache usually searches for an index.html, index.php, index.htm files in the WebRoot of the website you are loading. If it can’t find any, it will throw the 403 forbidden error.

Depending on the initial file your website should load, you can edit the website’s vhost file. In your vhost file, you’ll find a line that would look something like that

DirectoryIndex index.php index.html index.htm

Add the first file your website should load right after DirectoryIndex and restart Apache.

service apache2 restart

Regards,
KFSys

  • hi ,
    where is the vhost file ,
    i can’t find it

    • Hi @zainalabdeen,

      Depending on the OS the name of the folders is different.

      Ubuntu

      You can find the Apache directory at

      /etc/apache2
      

      There you’ll have a sites-enabled directory. Inside of it should be your config.

      CentOS

      You can find the Apache directory at

      /etc/httpd
      

      There you’ll have a sites-enabled directory. Inside of it should be your config.