temporary url on a DigitalOcean VPS

temporary url on a DigitalOcean VPS

With shared hosts, generally when you create a site, you get a temporary url which you can use for testing purposes even if the DNS settings on your domain name  haven’t yet been pointed to your shared host… with a VPS, you’re on your own. You don’t get a temporary url so you’re forced in to coming up with your own solution. I have a VPS running Ubuntu with Digital Ocean, so i’ll share how i get around the temporary url problem…

Stop talking nonsense. Explain the problem.

Let’s say you own a website called Google.com (lucky you). You have it hosted on a shared hosting package at GoDaddy. It’s quite popular and people are relying on it to be up 24/7. But you’ve decided that you want to move the site to your own dedicated server or VPS in order to handle the growth. You can’t afford to dick around with settings and have it go offline indefinitely while you try to figure out how to move it. The transition has to be a seamless experience for the end user…

This is where temporary urls come in handy. So your website might be Google.com but with a shared host you might be able to access the live site at 1245.godady.com/junkt~ed7291. So you can do all your testing and pre-launch checks there, just like a pilot does before taking off. Changing the DNS settings on your live domain name is like barreling down the runway at full throttle, beyond the point of return. After you’ve taken off is not the time to be testing whether everything is functioning correctly.

So as mentioned earlier, if you have your own VPS, you probably won’t be able to create temporary urls easily. But then again, you probably don’t need to…

Give me the solution.

In short, if i’m moving a site to a new location, i basically want to see the site working live in it’s new home before i change the DNS settings on the domain name. Or using the pilot analogy, i want to carry out all pre-flight checks and know that i’ve done everything i can to ensure the plane will fly before i take off. I don’t really need a temporary url, i just need to be able to access the website in it’s new home. How can i do that without a temporary url you ask?

Well, you can trick your PC or local network in to thinking that Google.com is hosted on [insert IP address here]. So when you type in google.com in to a browser, you’ll be diverted to [your IP] which in turn renders your website. This trick involves editing what’s called a ‘hosts’ file locally. On Windows, you’ll find it by going to Windows > System 32 > Drivers > etc (there’s a folder called ‘etc’, i don’t mean ‘etcetera’).


So if you want to test out your website in its new home before you change DNS settings (and why wouldn’t you?!) then you could edit the hosts file to include a line like so: google.com

or just to clarify…

[IP address of new host] + [space] + [url]

So what happens here is that once saved, any requests for google.com will direct to the IP In this case google.com will redirect to bing.com (how annoying would this be if you were an unsuspecting user!). Provided you’ve hosted & configured the site correctly on your new server, you’ll see it displayed in the browser and can test it out as normal. If you’re happy it’s all working, THEN you can change the DNS settings on the domain name to point at your new host. You don’t need a temporary url.

The transition for users will be seamless although it’s a little more complicated if you’ve a busy site with lots of users storing stuff in a database (in that case you’ll probably have to take the site offline briefly in order to prevent data from being lost during the transition from old host to new host).

But that, in a nutshell, is how you overcome the problem of not having a temporary url to play with. Don’t forget to remove the rule you just entered in to the hosts file too after you’re done. Generally there are 3 reasons why you’ll edit the hosts file:

  1. To restrict access to certain sites or just to prank people…
  2. To prevent software from reaching authentication servers… would you like to register your software and get free updates? No. Of course not. Not if you’re using pirated software. Hackers / pirates / privacy conscious folk may want to edit the hosts file… some for legal reasons, others for not so legal reasons.
  3. As I’ve pointed out here, for development / testing purposes.

So there you have it. A hacked solution which may not be pretty, but feel free to offer suggestions or alternative solutions in the comments 🙂

2 thoughts on “temporary url on a DigitalOcean VPS”

  1. Shared hosts and digitalocean are very different things and you don’t need a temporary url. With a shared host, you and a lot of other websites all use the same ip address. Using http 1.1 the domain name is how the server knows to show you the correct website. This is why a shared host needs a temporary url for you to setup with.

    DigitalOcean you get your own server with it’s own ip address that is not shared. You can just use the IP in your browser to get to the default website. If your setting up multiple virtual websites like a shared hosting company does then yes, this method is a great way to temporarily test. You also could just alter your own dns to add in your own temporary urls. That method I like better when your working with a team that needs to all check out the new server to make sure it’s ready for your production traffic.

  2. yep, I should have clarified if you just have the one website, then you don’t need this workaround, you can just go straight to the IP address…

    in my situation though i was hosting multiple sites on the same VPS so that’s why i needed a workaround 🙂

Leave a Reply