# Troubleshooting Connection Timeout Issue

## Problem
Connection timeout when accessing: `http://catalogue-builder.vehinc.co.za/public/`

## Common Causes & Solutions

### 1. **Document Root Configuration (MOST COMMON)**

**The Issue:** Your URL includes `/public/` which suggests the document root is not set correctly.

**Solution:**
- The document root should point directly to the `public` folder
- You should access: `http://catalogue-builder.vehinc.co.za/` (NOT `/public/`)
- In cPanel: Go to **Subdomains** → Edit your subdomain → Change Document Root to point to the `public` folder

**Correct Setup:**
```
Document Root: /home/username/public_html/catalogue-builder/public
OR
/home/username/catalogue-builder/public
```

**Incorrect Setup (causing your issue):**
```
Document Root: /home/username/public_html/catalogue-builder
Then accessing: http://catalogue-builder.vehinc.co.za/public/
```

### 2. **Missing .htaccess File**

Check if `public/.htaccess` exists. If missing, create it with this content:

```apache
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
```

### 3. **PHP Version Mismatch**

Laravel 12 requires PHP 8.2+

**Check PHP Version:**
- In cPanel, go to **Select PHP Version**
- Ensure PHP 8.2 or higher is selected
- Check if PHP-FPM or CGI is enabled

### 4. **Missing Vendor Directory**

If vendor directory is missing, you'll get timeout/fatal errors.

**Solution:**
```bash
# Via SSH or Terminal in cPanel
cd /home/username/catalogue-builder  # or your actual path
composer install --no-dev --optimize-autoloader
```

### 5. **PHP Errors Causing Hang**

Enable error logging to check:

**In .env file:**
```env
APP_DEBUG=true
APP_ENV=local
LOG_LEVEL=debug
```

Then check `storage/logs/laravel.log` for errors.

### 6. **Permission Issues**

Set correct permissions:
```bash
chmod -R 755 storage bootstrap/cache
chmod -R 644 .env
chown -R username:username storage bootstrap/cache
```

Replace `username` with your cPanel username.

### 7. **Memory/Time Limits**

Add to `public/.htaccess`:
```apache
php_value memory_limit 256M
php_value max_execution_time 300
php_value upload_max_filesize 64M
php_value post_max_size 64M
```

### 8. **Check Error Logs**

- **cPanel Error Log:** Check cPanel → Error Log section
- **Laravel Log:** Check `storage/logs/laravel.log`
- **PHP Error Log:** Check cPanel → Error Log or contact hosting support

### 9. **Test PHP Execution**

Create a test file `public/test.php`:
```php
<?php
phpinfo();
```

Access: `http://catalogue-builder.vehinc.co.za/test.php`

If this also times out, it's a server/PHP configuration issue, not Laravel.

## Quick Diagnostic Steps

1. **Check Document Root:**
   - cPanel → Subdomains → Edit → Check Document Root path
   - Should end with `/public`

2. **Test PHP:**
   - Create `public/test.php` with `<?php phpinfo(); ?>`
   - Access via browser
   - If this works, Laravel is the issue
   - If this times out, PHP/server is the issue

3. **Check Files:**
   - Verify `public/.htaccess` exists
   - Verify `vendor/` directory exists or can be created
   - Verify `.env` file exists

4. **Check Permissions:**
   - `storage` and `bootstrap/cache` should be 755 or 775
   - Files should be readable

5. **Check PHP Version:**
   - cPanel → Select PHP Version → PHP 8.2+

## Most Likely Solution

**90% of timeouts are due to Document Root pointing to wrong folder.**

Fix:
1. In cPanel, go to **Subdomains**
2. Click **Manage** or **Edit** for `catalogue-builder`
3. Change **Document Root** to: `public_html/catalogue-builder/public` (or similar)
4. Save
5. Access: `http://catalogue-builder.vehinc.co.za/` (without `/public/`)

## Still Having Issues?

1. Check cPanel Error Logs
2. Check `storage/logs/laravel.log`
3. Test with simple PHP file
4. Contact hosting support with error logs
5. Verify PHP 8.2+ is installed and active














