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

CVlaracasts's avatar

Forge edit Server fails to connect to a restored EC2 instance.

I use Forge and AWS EC2 for my Laravel app and MySQL DB. I performed an AWS Backup of my EC2 and restored the AMI to create a 'clone' of my EC2 to test a deployment.
When I attempt to edit the Forge Server details with the new instance IP details, Forge cannot connect to the server.
I have verified the Security Group is identical and other than the IP Address it should be the same server. Is there a way to update the existing Forge server to connect to this instance so I can 'test' without impacting my PROD server?

0 likes
2 replies
LaryAI's avatar
Level 58

When dealing with Laravel Forge and AWS EC2 instances, there are a few steps you can take to troubleshoot and resolve connection issues after restoring an EC2 instance from an AMI. Here’s a step-by-step solution:

  1. Verify SSH Access:

    • Ensure that you can SSH into the new EC2 instance using the same key pair that Forge uses. This will confirm that the instance is accessible and that the security group settings are correct.
    • Use the following command to test SSH access:
      ssh forge@<new-instance-ip>
      
  2. Check Security Group Settings:

    • Double-check that the security group associated with the new EC2 instance allows inbound SSH (port 22) traffic from the IP address that Forge uses to connect.
    • Ensure that the security group rules are identical to those of the original instance.
  3. Update Forge Server Details:

    • In the Forge dashboard, update the server details with the new IP address of the restored EC2 instance.
    • Make sure that the SSH key Forge uses is still valid and associated with the new instance.
  4. Verify SSH Key on the Server:

    • Ensure that the public SSH key used by Forge is present in the ~/.ssh/authorized_keys file on the new EC2 instance.
    • You can add the key manually if it's missing:
      echo "your-public-key" >> ~/.ssh/authorized_keys
      
  5. Check for Host Key Verification:

    • If the host key of the new instance differs from the original, Forge might be rejecting the connection due to host key verification. You can reset the known hosts file on Forge or update it to accept the new host key.
  6. Firewall and Network Configuration:

    • Ensure there are no additional firewall rules or network configurations that might be blocking Forge's access to the new instance.
  7. Reboot the Instance:

    • Sometimes, simply rebooting the EC2 instance can resolve connectivity issues.
  8. Contact Forge Support:

    • If the above steps do not resolve the issue, consider reaching out to Laravel Forge support for further assistance, as they might have additional insights specific to their platform.

By following these steps, you should be able to troubleshoot and resolve the connection issue between Laravel Forge and your restored EC2 instance.

CVlaracasts's avatar

@LaryAI Tried all of these steps already following a lot of Googling and no success.

Please or to participate in this conversation.