1

I am trying to deploy my laravel project to 000webhost. The problem is I can not connect to my database.

When I set my DB_HOST to 127.0.0.1 I get an "SQLSTATE[HY000] [2002]" error mentioned. When I change DB_HOST to localhost I get an error saying "wrong com stmt prepare response size received 7".

This is my .env file:

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:fuFWdq2OAIZbxiiouYdTfbPnkeEOL8h/hDJjvb7XT+c=
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=id1619178_kule
DB_USERNAME=************
DB_PASSWORD=************

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=mail
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null  
MAIL_PASSWORD=null
MAIL_ENCRYPTION=tls
MAIL_TO=
3
  • I have same problem in 000webhost when install laravel project. "wrong com stmt prepare response size received 7". But i could not solve. Commented May 14, 2017 at 12:21
  • @Marino Did you find any solution for it? Commented May 14, 2017 at 17:43
  • Sorry guys for waiting. I searched the phpmyadmin variables and found hostname. But now it seems the 000webhost is down for some reason and cannot connect to file manager so I have to wait to test it out. As soon as I test it I will let you know. Commented May 14, 2017 at 22:43

4 Answers 4

2

000webhost not execute command from .env file so you have to manually specifies that five variables in /config/database.php file

'mysql' => [
        'driver' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'database' => 'your_database_name',
        'username' => 'your_database_username',
        'password' => 'yourpassword',
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
    ],
Sign up to request clarification or add additional context in comments.

Comments

1

If you have a free plan in 000webhost, you can't do a remote connection. Only from your site.

Comments

0

Hostname for your given web host varies from server to server!

You can retrieve hostname from the control panel and add changes to your file else you'll get permission denied.

1 Comment

Thank you I will let you know.
0

Not all shared hosting provide MySQL on the same localhost as the HTTP server. You should check your cpanel for the address of the MySQL server:

From your hosting provider's documentation:

What is MySQL hostname?

You have go to our members' area, enter the control panel and click on the 'MySQL' icon. Your MySQL hostname will be listed there.

Important! Never use 'localhost' as your MySQL hostname here or you will get access denied errors!

Your specific provider states clearly that your should, "Never use localhost".

4 Comments

Thank you very much for your help, as I stated above I will test the hostname as soon as 000webhost becomes accesible.
this is my hostname - 9362.us-imm-sql2.000webhost.io stated in variables in phpmyadmin. Now the error is SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known obviously it is the wrong host?
It has nothing to do with the phpmyadmin address, you need to check your cpanel
Thanks, I asked on the 000webhost forum also the moderator stated DB_HOST is localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.