How to transfer localhost to server in Magento 2

Please follow below step

  • Copy source files and database
  • Update config file with new database location in app/etc/env.php
  • Go to database and change host in core_config_data table to new domain/IP

After complete above procedure and then clear cache with following command

php bin/magento indexer:reindex

php bin/magento cache:flush