Operating System & Version
CentOS 7
cPanel & WHM Version


May 12, 2020
cPanel Access Level
Root Administrator
I'm migrating from an old server to a new server running cPanel/WHM v86.0.18 and I'm in the process of migrating and testing two websites, let's say example.com and web.example.com.
These two websites are currently hosted on the old server, both with the same IP, let's say Obviously, the new server has a different IP, let's say, but the websites will have the same URL.
Now, example.com will make a PHP cURL request to web.example.com to authenticate the users on both the websites, but the problem I'm facing is that the cURL request on the new server is going to web.example.com: instead of going to the new IP, and this is understandable.
When I'm testing the websites on Windows, a simple edit to the hosts file will do the trick, but when I edit the /etc/hosts file in CentOS to point to the new IP, every cURL request fails and I can't even ping web.example.com without losing all the packets.

My question is: how can I reproduce the hosts file edit of Windows in CentOS? Is there a way in WHM to do it? Thanks.


Product Owner II
Staff member
Nov 14, 2017
I was able to do this successfully on my server by editing /etc/hosts using the same format you would on windows:

IPAddress            domain
For example I told my server that gmail was hosted locally:

104.145.xxx.xx          gmail.com www.gmail.com
[[email protected] /]# ping gmail.com
PING gmail.com (104.145.xx.xx) 56(84) bytes of data.
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=2 ttl=64 time=0.062 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=3 ttl=64 time=0.042 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=4 ttl=64 time=0.057 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=5 ttl=64 time=0.038 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=6 ttl=64 time=0.037 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=7 ttl=64 time=0.069 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=8 ttl=64 time=0.066 ms
64 bytes from server.mydomain.us (104.145.xx.xx): icmp_seq=9 ttl=64 time=0.079 ms
--- gmail.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 8000ms
rtt min/avg/max/mdev = 0.037/0.055/0.079/0.014 ms
[[email protected] /]# curl -vvI gmail.com
* About to connect() to gmail.com port 80 (#0)
*   Trying 104.145.xx.xx...
* Connected to gmail.com (104.145.xx.xx) port 80 (#0)
> HEAD / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: gmail.com
> Accept: */*
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Wed, 03 Jun 2020 05:22:08 GMT
Date: Wed, 03 Jun 2020 05:22:08 GMT
< Server: Apache
Server: Apache
< Strict-Transport-Security: max-age=300; includeSubDomains; preload
Strict-Transport-Security: max-age=300; includeSubDomains; preload
< Last-Modified: Mon, 27 Apr 2020 15:13:30 GMT
Last-Modified: Mon, 27 Apr 2020 15:13:30 GMT
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Content-Length: 163
Content-Length: 163
< Cache-Control: no-cache, no-store, must-revalidate
Cache-Control: no-cache, no-store, must-revalidate
< Pragma: no-cache
Pragma: no-cache
< Expires: 0
Expires: 0
< Content-Type: text/html
Content-Type: text/html

* Connection #0 to host gmail.com left intact