<\/figure>\n\n\n\nThe 403 Forbidden access means that the request is accepted by the server, but the server refuses to authorize it. The reason for this can be incorrect file or folder permissions, corrupted .htaccess file, or some plugin. To be sure about the file and folder permissions, you can set them to the correct one with the following commands:<\/p>\n\n\n\n
First, be sure that you are in the document root of your website<\/p>\n\n\n\n
cd \/var\/www\/html\/\n\nchown -R www-data:www-data .\n\nfind . -type d -exec chmod 755 {} \\;\n\nfind . -type f -exec chmod 644 {} \\;\n<\/pre>\n\n\n\nThe folders are with 755 and the files are with 644, while both are owned by the “www-data” user and group.<\/p>\n\n\n\n
If the .htaccess is corrupted then it is a good practice to recreate it or to restore it from the backup on the server or if you have it locally.<\/p>\n\n\n\n
The problem with plugins can easily be solved, by deactivating the plugins temporarily. To deactivate the plugins follow the steps below:<\/p>\n\n\n\n
Enter in the WordPress plugins directory<\/p>\n\n\n\n
cd \/var\/www\/html\/wp-content<\/pre>\n\n\n\nRename the plugins directory<\/p>\n\n\n\n
mv plugins plugins.backup<\/pre>\n\n\n\nRefresh the page and access your admin dashboard. Once everything is OK, go back on your server and revert the name from plugins.backup<\/b> to plugins<\/b> again. Enable the plugins one by one and see which one is the culprit.<\/p>\n\n\n\n<\/span>3. Error Establishing a Database Connection<\/span><\/h2>\n\n\n\n <\/figure>\n\n\n\nThis issue is related to the database itself, which may be caused by multiple reasons, like MySQL service, wrong database credentials in the WordPress configuration file, corrupted database tables, and etc.<\/p>\n\n\n\n
MySQL service:<\/b> Check if the MySQL service is up and running on your server with the following command:<\/p>\n\n\n\nsystemctl status mysql<\/pre>\n\n\n\nIf the service is stopped, you should see the following output:<\/p>\n\n\n\n
root@vps:\/var\/www\/html# systemctl status mysql\n\u25cf mysql.service - MySQL Community Server\n Loaded: loaded (\/lib\/systemd\/system\/mysql.service; enabled; vendor preset: enabled)\n Active: inactive (dead) since Wed 2021-12-01 15:31:21 UTC; 5min ago\n Process: 40051 ExecStart=\/usr\/sbin\/mysqld (code=exited, status=0\/SUCCESS)\n Main PID: 40051 (code=exited, status=0\/SUCCESS)\n Status: \"Server shutdown complete\"\n<\/pre>\n\n\n\nStart the service with the command below:<\/p>\n\n\n\n
systemctl start mysql<\/pre>\n\n\n\nWhen MySQL service is up and running you should receive the following output for status<\/p>\n\n\n\n
root@vps:\/var\/www\/html# systemctl status mysql\n\u25cf mysql.service - MySQL Community Server\n Loaded: loaded (\/lib\/systemd\/system\/mysql.service; enabled; vendor preset: enabled)\n Active: active (running) since Wed 2021-12-01 15:38:50 UTC; 1s ago\n Process: 40808 ExecStartPre=\/usr\/share\/mysql\/mysql-systemd-start pre (code=exited, status=0\/SUCCESS)\n Main PID: 40822 (mysqld)\n Status: \"Server is operational\"\n Tasks: 38 (limit: 4617)\n Memory: 360.1M\n CGroup: \/system.slice\/mysql.service\n \u2514\u250040822 \/usr\/sbin\/mysqld<\/pre>\n\n\n\nWrong Database Credentials:<\/b> You need to open the wp-config.php<\/b> file located in the document root of your WordPress website and pay attention to the entries shown below:<\/p>\n\n\n\ndefine( 'DB_NAME', 'wpdb' );\n\n\/** MySQL database username *\/\ndefine( 'DB_USER', 'wpdb' );\n\n\/** MySQL database password *\/\ndefine( 'DB_PASSWORD', 'Your-Strong-Database-User-Password' );<\/pre>\n\n\n\nIf the credentials are not correct please make sure to correct them and try to access the website again.<\/p>\n\n\n\n
Corrupted database<\/b>: This issue is related to the database tables and in order to check and fix them, you need to use the following commands with WordPress database user and password:<\/p>\n\n\n\nroot@vps:~# mysqlcheck -c wpdb -u wpdb -p \nEnter password:\n<\/pre>\n\n\n\nIf everything is OK, then you should receive the following output:<\/p>\n\n\n\n
wpdb.wp_commentmeta OK\nwpdb.wp_comments OK\nwpdb.wp_links OK\nwpdb.wp_options OK\nwpdb.wp_postmeta OK\nwpdb.wp_posts OK\nwpdb.wp_term_relationships OK\nwpdb.wp_term_taxonomy OK\nwpdb.wp_termmeta OK\nwpdb.wp_terms OK\nwpdb.wp_usermeta OK\nwpdb.wp_users OK\n<\/pre>\n\n\n\nTo optimize the database you can use the commands below:<\/p>\n\n\n\n
root@vps:~# mysqlcheck -o wpdb -u wpdb -p\nEnter password:<\/pre>\n\n\n\n<\/span>4. There has been a critical error on this website.<\/span><\/h2>\n\n\n\n <\/figure>\n\n\n\nIn this case, we do not know, what is the issue because by default the debug mode is not enabled in the WordPress configuration file. To enable the debug mode go to the document root of your WordPress website and open the wp-config.php file<\/p>\n\n\n\n
cd \/var\/www\/html && nano wp-config.php<\/pre>\n\n\n\nSearch the word “WP_DEBUG<\/b>“, and set it to true.<\/p>\n\n\n\n define( 'WP_DEBUG', true );<\/pre>\n\n\n\nOnce, the debug is set to true, save the file, close it, and refresh the website<\/p>\n\n\n\n <\/figure>\n\n\n\nNow, you can notice that when debug mode is set to true, we can see the exact error. In this case, it is some kind of syntax error on line 616<\/b> in the file at \/var\/www\/html\/wp-content\/themes\/twentytwentyone\/functions.php<\/b><\/p>\n\n\n\n
Once, the issue is fixed in the code of the theme you can revert the debug mode to false and refresh the page.<\/p>\n\n\n\n