Hosting a React website on Hostinger - Error 403

Tristan_Ruel

New member
Registered
Joined
Mar 6, 2023
Messages
1
Points
1
I am trying to create a React website and get it hosted. I've built the website and it works fine on LocalHost:3000, however, problems arise when I try to host it. I've used commands such as npm run build as well as yarn run build (hoping that it would change something, it didn't.). Additionally, I pasted the following code in my .htaccess file:

Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule . /index.html [L]
</IfModule>
I've attached a picture here showing the error on the right and my public_html folder where I unzipped the build file:

Contents of public_html directory

1


public_html directory

2


Nothing seems to be working and my website is simply showing error 403.

A few more random pieces of information:

  • My domain/website works fine as I was able to run a WordPress website on it beforehand with no issues
  • I'm using the "Premium Web Hosting" from Hostinger
  • I've made my website using React as well as NextUi
If anyone could provide some assistance as to what I might be doing wrong here and how to fix it, it would be greatly appreciated!! Do LMK if more information is needed.
 

David Beroff

Well-known member
Registered
Joined
Jun 14, 2016
Messages
1,498
Points
63
Hi there,

Here are some steps that may help you resolve the issue:

Check the hosting account permissions: It's possible that your hosting account does not have the necessary permissions to access the files on your website. Try checking the permissions on your hosting account and make sure they are set up correctly.

How to do:
- Log in to your hosting account and navigate to the file manager or FTP client
- Check the permissions for the website files and directories. They should be set to 644 for files and 755 for directories. If they are not, you can change them using the chmod command.
- Check if the hosting account has the necessary permissions to access the website files. This may involve checking the user and group permissions for the files and directories.

Check the file permissions: It's also possible that the file permissions are not set up correctly for your React website files. Try setting the file permissions to 644 for all files and 755 for directories using the chmod command.

How to do:
- Open your terminal or command prompt and navigate to the root directory of your React website.
- Type the following command to set the file permissions to 644:

Code:
find . -type f -exec chmod 644 {} \;[code]

- Type the following command to set the directory permissions to 755:

[code]
find . -type d -exec chmod 755 {} \;

Check the document root: Make sure that the document root for your website is set up correctly. The document root is the directory on the server where your website files are located. Check if the path is correct, and the document root has the correct permissions.

How to do:
- Log in to your hosting account and navigate to the file manager or FTP client.
- Check the path for the document root. This is the directory on the server where your website files are located.
- Make sure that the path is correct and that the document root has the correct permissions.

Check the .htaccess file: Make sure that the .htaccess file is present in the correct directory and has the correct code. The .htaccess file is used to configure the webserver and may be responsible for the 403 error if it is not set up correctly.

How to do:
- Open your terminal or command prompt and navigate to the root directory of your React website. b. Type the following command to check if the .htaccess file is present:

Code:
ls -a
- If the .htaccess file is not present, create a new one in the root directory of your website and add the following code:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
Try running the website on a different port: If all else fails, try running the website on a different port, such as 8080, instead of the default port 80. You can do this by modifying the configuration files on your server.

How to do:
- Open your terminal or command prompt and navigate to the root directory of your React website.
- Type the following command to start the development server on port 8080:

Code:
npm start -- --port=8080
- Access your website by entering the following URL in your browser:

Code:
http://localhost:8080/
If the above steps don't solve the issue, you may need to contact your hosting provider support for further assistance.

Hopefully, these steps will help you resolve the issue and get your React website hosted successfully. If you continue to have problems, don't hesitate to reach out to their support team for assistance.
 
Newer Threads
Replies
7
Views
1,236
Replies
2
Views
799
Replies
6
Views
1,295
Replies
1
Views
932
Replies
7
Views
1,274
Latest Threads
Replies
0
Views
122
Replies
1
Views
77
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top