You need to follow a few steps.
1) Delete the /var/cache folder.
2) Edit your /app/etc/loca.xml and change the database values.
3) Enter to the database, and look at the core_config_data.
You can run something like this.
SELECT * FROM core_config_data WHERE path = 'web/unsecure/base_url' OR path = 'web/secure/base_url';
There you gonna find the old url’s.
Change that values and Magento gonna be working again.