I want to use a remote host for my magento 2. the problem is even if I have set the host to remote in env.php, it is still using localhost. it seems the value for the host is just ignored.

   array (
    'model' => 'mysql4',
    'engine' => 'innodb',
    'initStatements' => 'SET NAMES utf8;',
    'host' => 'my_remote_host',
    'dbname' => 'my_db',
    'username' => 'my_username',
    'password' => 'my_password',
    'active' => '1',

I have cleared the cache by using.

  php bin/magento cache:flush

I have cleared the cache in browser too. It looks like my Magento 2 is simply ignore the value i set to the Host in env.php and keep using localhost as default.

  • Remove var directory once and test it in private mode of browser. Apr 11, 2017 at 9:22
  • Change file permission, Please check you file permission Apr 11, 2017 at 9:24
  • I have deleted everything in var folder, and clear cache in browser, same problem. The value I set to Host in env.php is simply ignored. and it is keep using localhost as default. Apr 11, 2017 at 9:29

2 Answers 2


here you can see working configuration of env.php.

return array ( ...
'db' => array ( 'table_prefix' => '', 'connection' => array ( 'default' => array ( 'host' => 'mysql56.sty', 'dbname' => '***', 'username' => '***', 'password' => '***', 'active' => '1', ), ), ), 'resource' => array ( 'default_setup' => array ( 'connection' => 'default', ), ),
... );

This file works fine at my local installation.


I found out why, it was because in Magento 2. if you have typed in a wrong remote host, which was in my case. then localhost will be using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.