PHP to Node.JS Migration – Retaining Your Cpanel E-Mail Account While DNS Migration

Hello folks,
If you are here on this blog, you might be searching for the ways to migrate your existing PHP website to Node.js.
In this blog i will try to explain, how you can point your existing domain to nodejs hosting and keep using the cpanel hosting for managing emails for your domain.

To start with, you will have to make sure of the following things:

  1. You have an existing linux cpanel hosting (shared/dedicated).
  2. You have hosted your nodejs application on some other hosting provider such as heroku/clever-cloud.
  3. You want the contents should be served from the nodejs hosting.
  4. You want the email accounts which you have been using should work as it is.
  5. You have an existing domain name registered say via Godaddy, example:
  6. Your nodejs application has a domain say
  7. Your Name Server for points to your existing cpanel hosting say
So now you want that should point to heroku server i.e.

Work to be done:

  1. Add your domain name in the alias of your project in nodejs hosting , i.e. add as alias in your heroku account for the
  2. The DNS of will have to be changed from your cpanel hosting (not from your domain registrar eg: godaddy)
Steps to follow:

For the first part i.e. adding custom domain to your nodejs app, steps are really easy.

For Heroku hosting:

  1. Goto your dashboard.
  2. Click on the application which you want to add custom domain.
  3. Click on settings on top right.
  4. Scroll down a bit, Click on Edit in the Custom Domain.
  5. Add both and over there
  6. Click on Save, Thats It!
For the Second Part which is a little tricky but still easy to do.

What do you need for this?

  1. The ip address of the nodejs hosting website on which it resides.
  2. Your main domain name.

To get the ip address of your nodejs hosting, try to ping it from your console/command prompt.

Alternatively you can take the help of websites which would give you the ip address of any website, for eg

Just put in the url of your nodejs app url say and it will show you the ip address of it. Copy that ip address to clipboard!

Steps to change your current DNS for main domain:

  1. Log into your Cpanel hosting, usually via by providing login credentials.
  2. Scroll down till you find heading as DOMAINS.
  3. Click on Advance DNS Zone Editor.
  4. Select the domain name from the drop down over there.
  5. Scroll down to the Zone File Records.
  6. Now you have to change 2 things over here, the Type A record and the cname record for your main domain.
  7. Click on edit in the row where its shows your main domain eg:
  8. You will have to change the ip address listed over there with the one which you just copied for your nodejs hosting.
  9. Save the record and scroll down where it says .
  10. You will have to change it CNAME for this record from to
Tada!!! you are done.

Now whenever you will open it will point to your herokuapp hosting and the fun part is that your email/ftp account for your existing cpanel will not get affected from this migration 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *