Search code examples
phplaravelforgelaravel-nova

Laravel SQLSTATE[HY000] [2002] Connection refused | Forge | AWS


  1. I connected github repo to the forge (forge connected to AWS) and installed nova
  2. Deployed it (so now it has been migrated by forge script) and it opens by default with URL - 34.201.135.133
  3. Database connected to GUI (sequel pro)
  4. I've made changes and want to migrate, but it shows message

enter image description here

My .env is

APP_NAME=Laravel
APP_ENV=production
APP_KEY=(copied from forge's .env)
APP_DEBUG=false
APP_URL=http://localhost`

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=(copied from forge's .env)

Is that correct that I'm doing it from mac terminal just by php artisan migrate? Or I have to do this operation after SSHing to server (if yes - how?).


Solution

  • From the above error, it seems, one of the following value is incorrect in environment settings/ .env file:

    1. Database Name
    2. Database User
    3. Database Password
    4. Database host

    Please note that Database host should point to the Private IP address of your AWS instance instead of localhost or public IP address.

    Also command needs to be run over SSH