Tutorial

HTTP error 403 - Forbidden

By: Rajesh P.S.

The HTTP error 403 - Forbidden typically indicates that the server has understood the request, but it refuses to fulfill it due to restricted access to the requested file or folder. This denial of access can occur intentionally, where the site owner has limited permissions, or it may be a result of misconfiguration. The server acknowledges the request, but it explicitly denies access to the resource, preventing the user from viewing or interacting with it.


How to Fix a 403 Forbidden Error

For end-users

The vast majority of the time, there's not much you can do to fix things on your end. Still, there are some things you can try.

  1. Refresh the Page
  2. Double Check the Address
  3. Clear Browser Cookies and Cache
  4. Check firewall settings
  5. Deactivate browser extensions
  6. Try Again Later
  7. Contact website administrators

For site administrators

There are three common causes for this error

  1. An empty website directory
  2. No index page
  3. Permission and Ownership error

An empty website directory

Make sure that your website content has been uploaded to the correct directory on your server.

Plesk server

When creating a website using Plesk, the platform not only sets up a new virtual host on the web server but also generates the necessary directory structure for the site. Additionally, Plesk populates these directories with specific initial content, ensuring that the website has the required files and data to function properly. This streamlined process simplifies website creation and setup for users, providing them with a functional site from the start.These directories are located in the corresponding virtual host directories :

On Linux: /var/www/vhosts/ 
On Windows: C:\inetpub\vhosts\ 

By default it creates the directories below:

/var/www/vhosts/example.com/httpdocs/

- domain's root directory (may be changed in the Domains > example.com > Hosting Settings);

When you connect with your FTP user, you just need to navigate into the httpdocs directory. Moreover, be sure to replace example.com with your actual domain name.

cPanel server:

In Plesk, the /home/example/public_html/ folder serves as the web root for your primary domain name. This means that any files placed in the public_html folder will be accessible and displayed when someone enters your main domain name into their web browser. Essentially, the content within the public_html directory is what visitors will see when they access your website.

When you connect with your FTP user, you just need to navigate into the public_html directory. Be sure to replace example with the name of your cPanel account username.

IIS:

Microsoft turn off the most basic features by default. Go to Turn Windows features on or off.

public_html directory
Internet Information Services

No index page

The default document on a web server is the initial file that is sent to visitors when they access your website. Typically, the default document is set to index.html or index.php, but it can be customized to any desired file. This ensures that when someone visits your site, the specified default document is displayed as the starting point of the website.

Index files option is set to Default at:

Linux: Domains > example.com > Apache & Nginx Settings
Windows: Domains > example.com > IIS Settings

To resolve this 403 Forbidden error, upload an index page to your httpdocs or public_html directory.

If you already have a home page called something else - example.html , you have a couple of options to change it:

  1. Rename your home page to index.html or index.php.
  2. Set up a redirect on the index page to your real home page.
  3. Set a different default home page in your .htaccess file.

HTTP Error 403.14 - Forbidden in IIS

The Web server is configured to not list the contents of this directory.

In IIS, a default document is not configured for the requested URL, and directory browsing is not enabled on the server.

How to enable directory browsing?
  1. Go to the IIS Express install directory.

  2. Run appcmd set config /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the server level.

  3. Run appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the site level.

Moreover, verify that the configuration/system.webServer/directoryBrowse@enabled attribute is set to true in the site or application configuration file

Permissions and ownership errors

HTTP Error 403.14 – Forbidden error can also be caused by incorrect ownership or permissions on your website content files and folders.

Permissions

  1. for directories
find /desired_location -type d -print0  xargs -0 chmod 0755
  1. for files
find /desired_location -type f -print0  xargs -0 chmod 0644

Additionally, if you know PHP runs as the user and not as "apache", then you can set PHP files to 600, for an extra level of security, eg:

find . -type f -name '*.php' -exec chmod 600 {} \;

Ownership

The concept of owner and groups for files is fundamental to Linux. Every file is associated with an owner and a group. You can use chown and chgrp commands to change the owner or the group of a particular file or directory.

Every Linux system have three types of owner:

  1. User: A user is the one who created the file. By default, whosoever, creates the file becomes the owner of the file. A user can create, delete, or modify the file.

  2. Group: A group can contain multiple users. All the users belonging to a group have same access permission for a file.

  3. Other: Any one who has access to the file other than user and group comes in the category of other. Other has neither created the file nor is a group member.

Users and groups can be locally managed in /etc/psswd or /etc/group .

Plesk server: domain - example.com, domainuser - FTP user
/var/www/vhosts/example.com/ - root:root
/var/www/vhosts/example.com/httpdocs/ - domainuser:psaserv
/var/www/vhosts/example.com/httpdocs/index.html - domainuser:psacln
cPanel server: account user - example
/home - root:root
/home/example - example:example
/home/example/public_html - example:example

The chown command is used to change file ownership settings. The basic syntax is:

chown owner-user file
chown owner-user:owner-group file
chown owner-user:owner-group directory
chown options owner-user:owner-group file

Nginx 403 forbidden error


Nginx 403 forbidden for all files, Nginx 403 error: directory index of [folder] is forbidden

The Nginx 403 Forbidden error is a status code that occurs when a client attempts to access a part of the web server without sufficient permissions. When Nginx accesses a directory, it typically tries to index it and provide a list of files inside to the browser/client. However, directory indexing is usually disabled by default, leading to the error message "Nginx 403 error: directory index of [folder] is forbidden." This error indicates that the client does not have the required permissions to access the directory or view its contents.

Incorrect Index File

The try_files directive in Nginx attempts to serve files in the order they are specified and sets the internal file pointer accordingly. If you are experiencing issues with directory indexing being turned off and encountering the Nginx 403 Forbidden error, it is likely due to the presence of a directory option in the try_files directive. This can prevent proper file serving and lead to the forbidden error when accessing directories without sufficient permissions.

location / { try_files $uri $uri/ /index.html index.php; }

to

location / { try_files $uri /index.html index.php; }

Incorrectly set permissions

To resolve the Nginx 403 Forbidden error that may arise from incorrectly set permissions, you can follow these steps:

  1. Change the directory permissions to 755 and the file permissions to 644. This can be done using the "chmod" command in the terminal or command prompt.
  2. Ensure that the user running the Nginx process has ownership of the files and directories. For example, you can set the user to "www-data" using the "chown" command.

By setting the correct permissions and ownership, you should be able to resolve the 403 Forbidden error and allow Nginx to serve the files and directories properly.

sudo chown -R www-data:www-data *

Finally, set the directory and file permissions as:

sudo chmod 755 {dir} sudo chmod 644 {files}

Conclusion

HTTP error 403 - Forbidden indicates that the server understood the request, but it refuses to fulfill it due to insufficient permissions. The client attempting to access a specific part of the webserver is denied access, either intentionally or due to misconfigured permissions.












两个鬼故事聂氏起名字拳皇全集罗姓小孩子起名关秀媚三级rebecalinares有意义的诗句起名字起宝宝起名大全网生辰八字免费起名唐起名男屠夫小姐419是什么意思网络语言仓储管理软件尾崎南海南鸡饭加盟管楚易家暴雪梅外地车可以进京吗早安总统大人ufc终极格斗冠军赛20101992年属什么牛b的签名给古代小孩起名字姓祖起名字男生山中访友有哪些字适合起名大全燕窝注册商标起名刻章申请汉阳客运中心免费起名商铺名字西爵牛排少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

两个鬼故事 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化