Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Khare's avatar
Level 7

Forge can't connect to Database (ENV variables are set)

Hey guys!

I'm trying to launch an application through Amazon AWS and Forge. However, I am running into some difficulties. Forge won't run migrations or the deploy the application the error resulting in:

Mon Jun 20 12:36:56 CEST 2016
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
From github.com:avidyx/avidyx-mvp
* branch            master     -> FETCH_HEAD
Already up-to-date.
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
Generating optimized class loader
Compiling common classes

                                           
[PDOException]                               
 SQLSTATE[HY000] [2002] Connection timed out  

I have set the environment variables as following in the Forge dashboard and .env file. I can successfully ssh into the server and run mysql from there using the forge username and password, but even though the same settings are set in the env file forge still does not want to connect. Below are the settings I am using:

DB_CONNECTION=mysql
DB_HOST=52.59.11.102
DB_DATABASE=avidyx_mvp
DB_USERNAME=forge
DB_PASSWORD= ***************

Why won't forge connect to the DB?

0 likes
1 reply
d3xt3r's avatar

use localhost as your DB_HOST

2 likes

Please or to participate in this conversation.