Your free hosting site needs to support custom domain names. It isn't enough to point the DNS for your domain name to their server. You also need to tell your host about your domain name and they need to configure their server to show your site for requests for that domain name.
Not all free hosting supports custom domain names. In fact most free hosts don't.
I never use free hosting and I never recommend that anybody else does either. If you are willing to spend $15 a year registering a domain, you can find a reliable web host for $50 per year. As How to find web hosting that meets my requirements? says:
- Free hosts have no obligation to offer you support.
- Free hosts have no obligation to keep your site running.
- Free hosts have little obligation to upgrade, maintain, and secure their servers.
- Probably advertising on your site.
In short, it's worth paying for hosting instead of using a free service. A cheap shared hosting package will give you a basic level of support, more reliable uptime, and it won't break the bank.
A CNAME is not sufficient to show the same content as some other site. A CNAME is also not a redirect. A CNAME says that the subdomain of a domain uses the same IP address as another site. When you use
www as the host name in your DNS CNAME configuration the client does these steps:
- The client looks up the DNS for
www.example.com. It sees that it is CNAME for
- The client does a DNS lookup for
mysite.hostingProvider.example and gets an A record with an IP address. Say
- The client opens an HTTP connection to
126.96.36.199 and sends a
Host: www.example.com header as part of the request.
- The server has to be configured to respond with the content for
www.example.com as opposed to the hundreds of other sites that it may be hosting. The server has no knowledge that the intermediary
mysite.hostingProvider.example was used in the DNS lookup process.
www is correct for the CNAME, however, it isn't working because the hosting server isn't configured. You need to log into your web host and add that domain to your account. With most hosting that is done by configuring a domain or an "add-on domain" for your account. Your free hosting may or may not support these.
There is one other wrinkle. A CNAME cannot be used for the apex domain without any subdomain. You can't use a CNAME for
example.com, only for
www.example.com. If you want users to be able to type in the bare apex domain and get to your site, you need to configure
A records with IP addresses.