Ad

SQLSTATE[HY000] [2002] Connection Refused For Laravel Site

- 1 answer

I get this error when i try to host my laravel project at 000webhost:

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `berita` where `id_berita` between 10046 and 10047)

This is my .env:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=id12858572_rpl_smkn2
DB_USERNAME=id12858572_rpl_smkn2
DB_PASSWORD=********

This is the first time i got this error, i have checked similar question, but it has not helped me. Any ideas what´s wrong?

Picture for DB_NAME and DB_USERNAME

Ad

Answer

I try to add this code in my .htaccess file

after this code :

# HTID:13056320: DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES BELOW
php_value display_errors 1
# DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES ABOVE HTID:13056320:

add this :

<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>
Ad
source: stackoverflow.com
Ad