My IP address changed when restarted server (instance)

Hi Craig, As a complete novice I followed your instructions to build a web server and setup magento 2.3. Everything worked great (thanks!) and i am looking forward to watching some more of your lessons.
Everything was installed onto an Amazon AWS ubuntu server. For some reason i decided to stop the server last night and restart it today… The problem is that when you restart an ‘instance’ it assigns a new ip address to the server.
I can still connect to the server with Putty and PhpMyAdmin with the new ip address but i have no idea how to connect to the magento front or back?
Can you please help or is it easier to restart everything from the beginning again?

Hi @Andy and welcome!

It seems unusual to me that restarting an instance would change the IP address of a server… Unless it’s a completely different server being spun up. But from what you’re saying, it would mean that each time you restart then you would have to update your DNS settings for your domain name - Which is crazy.

To answer your question it depends on your Scenario… Bot are simple enough and should take less than 10 minutes with hardly any steps.

Scenario 1: Domain name is setup

This assumes that you connect to your Magento store via a Domain Name.

All you need to do is update your DNS settings of your domain with your Domain Provider. Therefore, example.com now points to <new ip address>. This can take up to 72 hours to propogate.

Scenario 2: No domain setup

This assumes that you still use an IP Address to connect to your Magento store.

Update both your BASE URL and SECURE BASE URL with the new IP address. This can be done via phpMyAdmin or CLI (Putty).

Option 1: phpMyAdmin

In the core_config_data table, look for a path web/secure/base_url and web/unsecure/base_url. Update the values for each to the new ip. E.g. http://123.123.123.123/

Option 2: CLI

Run both commands, where 123.123.123.123 is your new IP. You need to run these commands from the Magento Root Directory as the “Magento User”:

bin/magento setup:store-config:set --base-url="http://123.123.123.123/"
bin/magento setup:store-config:set --base-url-secure="http://123.123.123.123/"

Once you’ve updated your IP via either phpMyAdmin or CLI then you’ll need to clear your Magento Cache:

bin/magento cache:clean

You may also need to clear your browser cache incase your cookies get confused.

Further reading/research

You might also find Chapter 6 (URL Setup) useful in How to migrate Magento 2 from one server to another as I’m pretty sure I cover updating the BASE URLS via phpMyAdmin in this video.

Hi Craig,
Thank you so much for your quick reply!!
I made the modifications in phpMyAdmin and then cleared the cache as you advised in scenario 2 and it worked perfecty.
Thank you again!