Wednesday, October 27, 2021

[SOLVED] Aws wordpress EC2 with 503 service unavailable

Issue

This is my first time using wordpress on EC2 (I have 0 knowledge about it. I just follow youtube tutorial...). It was fine when I created in July until last week. I ran into 503 error

Service Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.

and saw articles saying the instance load balancer needs to set to a target group(I follow AWS documentation but it shows unused). Can anyone help me? My site is been down for one week already :( Thank you.

Edit: I ssh into the instance and saw my port 80 and 443 was block. So I rerun it make it active and my site is back again. For the targets I had 301 error code and I change the health checks success codes to 301 and its now healthy.


Solution

The target group is not receiving traffic from the load balancer it seems.

Remove the instance from the load balancer. Then configure the load balancer to send traffic to the target group.

If you don't see target group option in your load balancer, you must be using a classic load balancer. You can instead use an application load balancer.

this is what you can do:

  • Elastic load balancer:

remove the instance from the ELB, because you don't want to use the elastic load balancer, we will create an application load balancer

  • Target Group

Ensure you have healthy instances. If you don't have healthy instances, check your health check. is your heath check logic seems correct. is it http, and port 80, and the health check path is / ? does the path return 200 OK response.

  • Application load balancer

When you create an application load balancer, first you will select the subnets that you want to use, after that it will let you choose an existing target group. again choose the correct protocol, port options.



Answered By - Arun K