How to Setup WordPress on AWS EC2 instance – Part3

Now we have created our own WordPress Site as part of How to Setup WordPress on AWS EC2 instance – Part1 & How to Setup WordPress on AWS EC2 instance – Part2 . With this we can launch our own website and manage the same.

Though it looks easy to install, configure and manage WordPress, there are quite few errors which will cause a concern. Below are some errors and resolutions which i have come across.

1) ‘Error establishing database connection‘ . – This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.


This is mostly to do with DB connection.

  • Could be because restrictions at Security Group. Try giving ‘Allow All’ and check if that works, then slowly add other Access types and remove ‘Allow All’.
  • Proper Security Group not attached, modify the one at RDS console and add the correct Security Group.
  • DB itself is down, restart it.
  • wp-config.php file already exists with incorrect DB details, replace the db details there.

2) Migrating EC2 instance from one IP to another IP. A very common issue we may face is when we Stop and Start our EC2 instance. And if we have not assigned a Static IP, everytime a new IP will be assigned, due to this our DB will not be able to connect back to Application server. For this case follow the below,

  1. Advice you to take back up of your wp-config.php file and your Database before proceeding.
  2. ssh -> go to ‘/var/www/html/’ open wp-config.php. And add a new row  define(‘RELOCATE’,true).
  3.  Log into mysql db and update the below tables,
    1. update wp_options
      set option_value = ‘‘ — replace this with your new IP
      where option_name = ‘home’;
    2. update wp_options
      set option_value = ‘‘ –replace this with your new IP
      where option_name = ‘siteurl’;
    3. Or update across
      1. update wp_options set option_value = replace(option_value, ‘<<your old ip>>’, ‘<<your new ip>>’);


You may also like...

1 Response

  1. October 19, 2018

    […] part-3, we will look into resolving common errors during WordPress site […]