How to change the hosts file. What to look for


Why should you be very careful about the site transfer process? It's very simple: even one wrong action can lead to the fact that the site will become unavailable for some time. As a result - the loss of visitors, subsidence of queries in search results and even sanctions from the outside search engines up to excluding pages from the index. You can find many stories on the network about how people then recovered their resources for a long time after moving to another hosting ...

Before that, how to change hosting provider, I re-read about two dozen different articles that I found on this topic on the Internet. As a result, I got the impression that 99% of the authors of these articles have NEVER moved their own site. The articles were written clearly without knowledge of the case - just a SEO-optimized text and some kind of theoretical reasoning. I do not advise anyone to use what is written there, because the consequences can be very different).

In this publication, I will outline the safest and most painless way transferring a site to another hosting, which will pass completely unnoticed for you and your visitors. This instruction has been successfully tested by me on 5 of my sites. Only in the very first case, I ran into a small problem, which I quickly realized later and made the necessary adjustments to the instructions (I will talk about this in a little more detail below). So, let's begin…

Hosting change instructions

1. Do not wait until the money on your account on the previous hosting runs out completely! Start moving in advance, when you still have at least 2-3 days in stock. It is very important!

2. Disable the ability to leave comments on site publications. Create a full backup of the entire site folder (via FTP access) and database (via phpMyAdmin).

3. On the new hosting, create a site with the same name (for example, mysite.ru) as on the previous hosting. Add the domain to your control panel and link the domain to the site.

4. Copy all files from the site backup to the new hosting. Please note that the structure (nesting of folders) is identical. For example, mysite.ru -\u003e public_html. Accordingly, all files from the public_html folder of the backup must be copied to the public_html folder of the new hosting.

5. In the meantime, while copying is in progress, create in the control panel or via phpMyAdmin new base data. Import tables from the backup into it.

6. After all site files are copied, you need to connect the created database to the site. For WordPress: open the wp-config.php file and change the values \u200b\u200bof the parameters DB_NAME, DB_USER, DB_PASSWORD to the new ones.

In principle, everything is already ready - your site has been copied to a new hosting and can already work after changing DNS addresses). But take your time! We must make sure that the move was painless and did not cause any "glitches": violation of encoding, plugins, scripts, etc. To do this, go to the next stage ...


7. In the control panel of the new hosting or from their technical support, find out the IP-address at which your site will be located after moving to them. For example, for mail.ru it is 217.69.139.201

8. Find the file named hosts on your computer disk. In the operating room windows system 7 he's on the way c: \\ Windows \\ System32 \\ drivers \\ etc \\ hosts... Open it for editing and make a record like this:
217.69.139.201_mail.ru_www.mail.ru
Replace the above IP and domain name with your own !!! Use spaces instead of underscores !!!
Save hosts file.

9. Now start your browser (if it was open - restart it) and open your site. Your site will work with the new hosting! Check that everything is working correctly and that there were no problems after moving to a new hosting.

Moving on to the final stage ...

10. Go to the website of your domain name registrar and in the control panel change the addresses of the DNS servers to those given to you by the new hosting provider during registration.

Later certain time (from several hours to 3 days) Your site will start working with a new hosting! Site move completed! Please note: the copy of the site on the old hosting continues to work! We didn't delete it! Why this is needed - I'll explain now ...

Remember, at the beginning of this article, I said that when transferring the first site I ran into a small problem? The fact is that in addition to the delay in updating the DNS servers data (from 2 to 72 hours), there is also a delay in updating the DNS data of your Internet provider, which can also take up to 3 days. Therefore, if immediately after moving the site to a new hosting, delete its version on the old hosting (as most articles teach), then some of the visitors will become unavailable: the provider STILL does not know about the new IP of the site, but according to the old one, it ALREADY does not find it).

Moreover, there is another joke)). Your ISP has more than one server, and each server has its own DNS cache refresh period. As a result, a comical situation arises (tested on our own experience): your site opens, but your neighbor does not, even if you have the same Internet provider)).

The inaccessibility of the site for at least some of the visitors for some time, especially if it is 1-2 days, leads to a catastrophic decrease in traffic rates and behavioral factor, well, what does this lead in turn, I think it is not worth explaining ...

Therefore, after you completely transfer the site and change the DNS servers, do not rush to delete the site on the old hosting! Let him work there for 2-3 days. At this time, do not publish new articles, so as not to violate the identity of the site content on the new and old hosting. Comments, however, can be turned on immediately after the move - as you remember, we turned them off before creating a backup.


Well ... Now you know how painless and lossless change hosting for the site... Guided by this instruction, you will not lose a single visitor, and the whole process will go completely unnoticed).

Important note! This instruction is designed for those users who know what FTP is, how to make a database backup in phpMyAdmin, who is a domain registrar and how to change its DNS servers, etc. I deliberately did not "chew" these questions, as I am sure that if You do not know all this, then transferring the site to another hosting on your own is categorically contraindicated for you, because the consequences can be the most irreversible! It is better to entrust this business to professionals and sleep well). Good luck!

Sometimes it becomes necessary to change the hosting provider, for example, you are not satisfied with the cost of services or their quality. Many consider the procedure for changing hosting difficult and because of this they postpone it or do not dare at all. But if you understand and decompose the work plan in stages, everything becomes not so scary. The site can be transferred quickly and painlessly (without downtime in the site) by performing a certain sequence of actions. The main thing is that when transferring the site, it should be in working order for some time both on the new and on the old hosting. So:

  1. You should start by looking for a new suitable hoster. To do this, you can use our rating of hosting providers and read the article "how to choose a hosting".
  2. After choosing a new hoster, go to the old hosting and download a fresh backup of files and a backup of the database.
  3. We upload files and database to the new hosting and set up a connection to the database. Read more about this in the article "How to transfer a site to hosting".
  4. If you use mail on your domain and the hosting provider's mail servers must serve it, then all mailboxes you need to create anew on a new hosting.
  5. Next, it is imperative to check the work of the site on the new hosting. Some hosting providers have for this service address site, which is very convenient. If there is no such option, then you can do it using the "hosts" file, which is on your computer. On Windows it is usually found in WINDOWSsystem32driversetchosts, in Linux in / etc / hosts, in Mac OS in / private / etc / hosts. You need to open this file for editing and add an entry of the form X.X.X.X example.com. Where, instead of X.X.X.X, we indicate the IP address of the server of the new hosting, and instead of example.com, the name of your domain. Thus, you indicate to your computer on which IP address the site with the specified domain name is located. After checking the functionality, this entry in the "hosts" file must be removed.
  6. After that, you can start setting up a domain name so that the domain "looks" at the new hosting. There are two options here.
    1. Go to the domain name settings and specify the IP address of the new web server in the A records and the addresses of the mail servers in the MX records.
    2. At the domain registrar, in the domain settings, specify the DNS server of your new hosting provider. And then make all the necessary settings on the side of the new hoster.
    The second option is preferable. Firstly, it is more logical to manage both the domain and the hosting in one place, and secondly, the new hoster will most likely have all the necessary settings automatically specified and you will not have to do anything other than changing DNS servers for the domain. Also, it is likely that the hoster, in the course of work, needs to make changes to the settings of client domains, for example, when moving a site to another server with a different IP address. If a third-party was used for mail postal service (for example Yandex, google, etc.), then after changing DNS servers, you need to use new DNS servers specify the same information in MX records that was indicated on old DNS servers.
  7. After changing the domain name settings, there is no need to rush to delete or disable the site on the old hosting. It is necessary to wait while the information about the domain is updated on the DNS servers of Internet providers. The fact is that Internet providers for some time (from 8 to 72 hours) remember (cache) information about the domains that their clients accessed (). Accordingly, any changes to the domain name settings do not take effect immediately. At a certain point in time, it may turn out that some visitors still get to the site on the old hosting, and some already to the site on the new hosting. Usually it is enough to wait about a day.
  8. After updating the domain information, you can safely delete the site from the old hosting.
That is, in principle, the whole instruction, all actions can actually be performed within 1 hour. The only problems that can arise is with sites to which visitors regularly add information. As mentioned above, Internet providers cache information about domains, the frequency of updating this information is different for different Internet providers. Someone updates it every half hour, someone once every few hours, someone once a day, and someone may not cache it at all. As a result, it may turn out that the information on the site was added before the domain information was updated from the Internet provider and, accordingly, it will be saved on the old hosting. Unfortunately, this moment cannot be bypassed in any way, the only thing that can be recommended in such a situation is to change the hosting during the minimum activity of visitors, for example at night.

In the previous article, I talked about how you can make sure in advance what is on your site. But it is still very scary to register new NS addresses with the registrar.

What if something goes wrong? Suddenly the hoster will start to freak out or something else. And you will not be able to return to the previous hosting urgently, because DNS update takes from several hours to 3 days (and from experience, a small percentage of visitors visit the site using the old IP address even after a couple of weeks).

How to check site performance on new hosting

This is the simplest and most common knowledge. To check if everything works correctly after transferring files and database, but without changing NS records, you need:

  • Find out the new IP by which the site will be available on the new hosting
  • Open the file “ c: \\ Windows \\ System32 \\ drivers \\ etc \\ hosts»
  • Add a line at the end of the file: ip_site_name
  • Save file

You should get something similar:

The only caveat, if you open the "hosts" file with notepad, you must first start "Notepad", then transfer the file to it with the mouse. So we say our Windows versions XP / 7/8/10, that you need to open this site from just such an IP address.

How to change hosting without harm

We checked it, everything works. It remains to change the ns-server records at the registrar, but this is not at all necessary! To test the work of the new hosting provider live on regular visitors, we need to change the site's IP address in the current hosting panel.

Note: the method works if the hosting supports working with a DNS zone, and any normal (and even not so) provider has it.

The most popular panels are ISP Manager and cPanel, and I'll show them by example.

ISP Manager

We go to the control panel and look for "Domain names" at the very top. We click, and on the right we see our site, and on top of the button "Records" - click:

A list will appear, at the very top of which there should be an A-record. Ie, in the first column your domain name, in the column "Type" -\u003e " A" or " A (Internet v4 address)»:

Now we change this record (or both, if available from “www.site.ru”) using the “Change” button:

Now the most important thing: in the field "IP-address" you need to enter the IP-site on the new hosting. If there is a TTL field, then replace its value with "300". It depends on him how quickly "the site will move". That's it, click "OK", remove the entry from the "hosts" file (if you did it at the previous stage), and wait for the site to start visiting on the new server. From the TTL value, this time can take from 5 minutes to a couple of hours.

And now, if we are not satisfied with something in our work, we can return the old IP-address as long as the old hosting is paid for (you saved the IP value before replacing it? :)) And the most joy is that since we changed TTL to 300, then the "return transfer" occurs within 5 minutes! After all the final work, it is better to put "3600".

All this is enough to check the work of all the main functions of the site. At the same time, domain mail may not work or work in the old way (until the full ns change).

Using cPanel as an example

Everything is the same in the cPanel control panel, only it looks different. In the main window we find the "Advanced DNS Zone Editor"

Also find the A-record of the domain at the top and click "Edit". In the window, enter the new IP address and TTL value:

We save everything!

How to be 99% independent of hosting stability?

We will use my method not only for moving, but also for the stability of the site. You don't have to move, but have two hosters! This is a bit prim, but for those who do not have frequently updated sites and cannot afford double overpayment, I recommend it!

The principle is simple: the first hosting is used mainly as a DNS hosting, i.e., in the editor, we register the IP site on the second, main server. For these purposes, I chose it because it has a fast and stable DNS according to the ping-admin.ru rating. Also, it is taken into account that the servers will cope with the load on the site.

The second hosting is used as the main one. And if something happens to him, then we go to the admin panel of the first one and change the IP of the site to the native IP of the first hosting. After setting up the work, we change it back. I use the main one.

The disadvantage of this method is that the current copy of the site must be supported on both servers. But even if there is a slightly outdated copy on the backup server, it is still better than the inaccessibility of the site, especially in the eyes of search engines 😉

Here's a parsley, good luck!

If you are faced with the question of how to change hosting, imagine that you are moving to a new office, only this move is virtual. Choose a new location, sign documents for renting hosting space, "package" your site, transfer data, and then specify your domain by changing the DNS record. The final step is how to hang a sign on your new office door.

Choosing a new web host


There are a lot of providers, and each has its own configuration - a shared server, a dedicated server, a cloud VPS. To choose a hosting, you need to evaluate a number of factors, including cost, required space, server configuration. Today cloud solutions have become the best option for us, details of which can be found here www.colobridge.net (https://www.colobridge.net/products/cloud_solutions/cloud_vds.php). They have many benefits, for example:

  • Low costs.

  • High-speed performance.

  • Enhanced security.

  • High mobility.

  • Unlimited scalability.

  • Strict compliance with standards.

  • When purchasing, consider registering a domain with a third party provider. Should one ever need to quickly change the hosting of a site, the domain can move easily and without potential complications.


    Copy site

    If you have already solved the question of how to choose cloud hosting, proceed to the stage of copying the site to the cloud. To create backup static site, just copy the old file structures to the new web host. For a dynamic site that runs on a database (MySQL), install the web applications in the new location just as they are currently on the existing site. Then move the database file to the new web host.

    Last check

    Check if everything works as expected after uploading files to the new configuration. You can view a site hosted in the cloud vps using a temporary URL. Some hosting companies even provide a staging platform to preview the site before releasing it in a new environment. Thanks to this, possible disadvantages can be corrected.

    Switching site DNS records

    DNS records are like a list of instructions that determine where to send a user. Moving a DNS record to new server ensures that visitors can find the site as intended, and not receive an error message or go to the wrong place. Then you just have to wait. It usually takes 24-48 hours for domain name servers around the world to receive an update that the domain has a new location.


    Moving to a new web hosting, especially such as cloud hosting, is the best thing to do if you are not comfortable with the functioning of the site. This shouldn't be a problem, because this is a simple copy and download that you do daily.

    • high cost of services.

    Site transfer procedure

    All Internet resources can be divided into two groups: with and without databases. Regardless of this, the site transfer scheme is the same and consists of several stages:

    Checking the configuration

    Moving site content

    Most webmasters one day face the need to change hosting due to unsatisfactory service. Periodic or long downtime, poor or rude technical support, and sometimes even complete silence on the part of the hosting company are some of the reasons why people decide to change their hosting provider.

    Another reason for this decision is that the level of service does not match the requests of the website. Perhaps the site has very high traffic or it requires power that only a dedicated server can provide. Regardless of the reason for changing hosting, to move your site quickly and safely, follow these steps.

    Find good hosting
    If this is your first website (and hosting), then you will need help and the support specialists of a good hosting provider will provide it to you. If you are satisfied with the current hosting, but want to switch to a cheaper one, remember that it can be much worse than the old one and you will have to pay more for the usual level of service. If your current hosting is bad, then switching to another bad hosting won't gain anything. No need to worry about having to pay a higher price for best service - you usually get what you pay for. You need to break the vicious circle and find quality hosting.

    Back up your site
    Experienced webmasters always have backups of their sites. They often put the same copy in two different places: in different hard disks, to hard drives and CDs, etc. Most hosting companies claim to make regular backups. Although they can store backups, it is unlikely that they use serious backup subsystems, primarily due to their cost. Either way, an extra copy won't hurt.

    You should also be aware that hosting companies usually do not guarantee the security of your data. If you read their Terms of Service (TOS), you will find that they are not responsible for data loss. Also you may find that the backups they make are for internal use and are not issued to customers. And while this can sometimes be negotiated (for a fee), it's better to have your own up-to-date backups.

    Either way, the first step towards a new hosting is to copy the site's content (usually done with an FTP client). Make sure that the directory structure remains unchanged. If you change it, the site will not work properly in the new location.

    If the website is very large, ask your current provider when is the best time to back up. If you load the server too much, the hosting provider can stop the backup process or even shut down your site.

    Check the site in a new location
    After creation account, the new hosting provider will send you an email with your password, IP addresses you can use to access your account or website, DNS server addresses, etc. If the email does not contain complete information or you are unsure how to use it, ask your new hosting provider for help. If you chose good company, they will be happy to help you.

    Copy the site to a new location and configure account settings and email addresses, set file permissions and passwords on directories. Test as many pages as you can. Check if internal links are working correctly. Make sure you can connect to the server email and send a message.

    Any hosting provider knows that new customers usually need more tech support in order to get websites up and running. Generally speaking, a lack of support at this stage is not a good sign. If you are not satisfied with the level of technical support, then, perhaps, despite all your efforts to find a good hosting, you did not find what you were looking for.

    Move databases
    If your site uses a database, the migration process is slightly more complicated. Regardless of the situation, first figure out what you need to do to get people visiting your old site to actually use the new database hosted on the new hosting. Before changing anything, create a database on the new hosting with the same name as on the old one. Make sure everything is working correctly. You should do your best to spot any potential problems at this stage.

    Now let's look at a few ways to reduce downtime.
    If the database is not used often, or you can accept that data recently added by users may be lost, or if you are the only one adding information to the database, you can change hosting without downtime. All you need to do is copy the database to a new location. If your visitors or you regularly add data, make sure that the new base is used by the old site.

    If new content is added to the database very often, then things get much more complicated and there is no perfect solution. In any case, talk to your programmer or new hosting provider about it.

    How to change hosting

    The problem is that the chances of database changes are too high while you copy it from the old hosting to your computer and then to the new hosting (especially if the database is large and the connection is slow). Add in the time to change the settings of the old site so that it starts working with the new database, and you will realize that while you were doing all these movements, some data may have ended up in the old database.

    Another move strategy is to temporarily close the site and notify visitors. Even the sites of prestigious companies are closed from time to time for maintenance. There is no shame in this - there are many things that cannot be done while the system is running.

    Prevent Lost Email
    To make sure you don't lose emails, create new accounts in your email program. Most hosting providers assign mail server an address like "mail.yourdomain.com". At the time the DNS servers change, "yourdomain" can point to both the old and the new host, so you won't know where your email is going. To overcome this problem, you can set up two accounts in your email program for each "@ yourdomain.com" email address, using not "mail.yourdomain.com" for the incoming mail servers, but the IP addresses sent to you by each of the hosting -providers at the time of creating accounts.

    Change DNS
    The name servers associated with your domain name are used to locate the server that hosts the site. Their names are usually similar to "ns1.hostingcompany.com" and "ns2.hostingcompany.com", however, they can be different. Once you are fully satisfied that the site is behaving correctly, you can change the DNS. This means that you have to use your account with a domain name registrar, or ask the registrar to change the DNS.

    After dNS record will be changed, it usually takes up to two days for the change to take effect. However, some ISPs may use the old DNS for a longer period of time, sometimes up to two weeks, so it is best not to close the account with the former hosting provider for a while. Check if mail arrives at the old host and if any activity is recorded in the log files of your old account. As a rule, within two to three days all activity on the old hosting stops.

    Usually after two weeks, all activity on the old account should stop and you can notify the hosting company that you no longer need its services. Do not forget to return the money that the old hosting provider may owe you (if you paid in advance). This is your money and you have the right to return it. In any case, read the "Terms of Service" first, with which you agreed at the beginning of cooperation. It may turn out that after a certain period of time, you lose your right to any refund.

    The number of hosting providers today is in the hundreds and even thousands of companies. It is quite difficult to find among them a site that meets all the requirements of a webmaster. It is possible to draw conclusions about the convenience of cooperation and the quality of the site's work on a particular hosting only after some time, so the owners of Internet resources often have to face the issue of changing the provider.

    Possible reasons for website transfer

    The procedure for changing a hosting site requires a certain investment of time and effort, so there must be good reasons for making such a decision. These include the following factors:

    • unsatisfactory quality of work. Low speed page loadings, frequent errors - a good reason to change your hosting provider. However, you should first make sure that the cause of failures is the quality of the hosting, and not problems on the site side (there is no page caching, CMS optimization has not been performed, "heavy" graphic elements are used, etc.);
    • high cost of services. On the hosting market, you can always find better deals, but you should take into account the price-quality ratio. It is possible to reduce the cost of hosting below the market average only at the expense of certain costs (number of support staff, equipment capacity, license acquisition, etc.);
    • dissatisfaction with the work of the support service. From efficiency and quality technical support platform specialists determine the comfort of staying on it not only for novice users, but also for experienced webmasters. Therefore, the lack of timely and qualified assistance is a significant reason for changing hosting.

    In order not to step on the same "rake", you should carefully check the similar parameters of the new hosting site.

    Site transfer procedure

    All Internet resources can be divided into two groups: with and without databases.

    How to painlessly change your hosting provider?

    Regardless of this, the site transfer scheme is the same and consists of several stages:

    Making a backup file structure and databases
    The task can be solved using standard hosting control panel tools (file manager, PHPMyAdmin) or using special scripts.

    Switching the site to maintenance mode
    For projects created on the platform of one of the CMS, just run a special command in the management console. For simple HTML sites, you will need to create and download a special stub page.

    Checking the configuration
    Before moving, you should check the new hosting for the compliance of PHP versions and configurations, PHP modules connected, and available memory space for executing scripts.

    Moving site content
    The copied archive with the site files is unpacked to the root directory of the file structure on the new site. If the site uses a database, you should create a new database and import the previously created original archive into it.

    Changing the domain-hosting link
    Bind domain name There are two ways to access the new hosting: specify dns addresses in the administrative panel of the domain name registrar, or transfer the domain to the selected hosting provider.

    Check site functionality
    After moving and starting the site on the new hosting, you should check the correctness of the work of forms, widgets and other installed functionality.

    Many hosting providers offer new users a free site transfer service to their platform. For novice webmasters, this will save time and painlessly go through the procedure of moving to a new hosting.

    Its success depends on the quality of the hosting on which the Internet resource operates. Therefore, you should be very careful when choosing a hosting provider. If you initially made a mistake, you can change the hosting by transferring your site to a new one.

    Reasons to change hosting

    You should consider changing hosting when:

    • server uptime is low;
    • the admin panel is inconvenient;
    • backups are not performed as often as we would like;
    • technical support is irregular, and in case of contact, its specialists show incompetence;
    • site (s) are slow.

    If all or several of the above aspects apply, you should consider changing your hosting.

    Hosting change algorithm

    When you have made a decision to change hosting, you should follow a clear algorithm. First of all, you need to make a backup copy of your site. Typically, an archive is created first with file manager in the hosting panel. After that, using FTP, it is saved to hDD... During the saving process, you should definitely make sure that the original directory structure remains unchanged. If you own a large Internet project, then before starting to copy it, it is advisable to consult with the technical support service. Then, using the FTP manager, the site is uploaded to a new virtual or dedicated server.

    How to change hosting

    To move the site to another hosting, it is not enough just to copy and download it. You also need to make all the required settings for your resource - configure an account, set access rights, specify the necessary passwords, including for e-mail. If you encounter problems while performing these actions, the support service will certainly help you.

    Friendhosting is a great helper

    There is some good news for those customers who have opted for Friendhosting's web hosting. First, your site's speed will be optimal. Secondly, technical support specialists work around the clock. Thirdly, the stability of the Internet resource is ensured by a competent team of specialists and high-quality software the hosting itself. You will no longer have a question about how to change hostinghow to deal with problems with the site, etc. Your resource will function smoothly!

    Order high-quality VDS