What is web hosting and how does it work?

Web hosting is a server connected to the internet that stores your website's files and sends them to the browser of anyone who visits. Without it, your site would only exist on your own computer.

Updated 5 min read

Learning objectives

After reading this article you will be able to:

  • Understand what happens between typing an address and seeing the page
  • Tell shared hosting, VPS, dedicated servers and cloud apart
  • Know what to check before choosing a host
On this page

A website is a set of files: HTML, CSS, JavaScript, images and, on dynamic sites, code that runs on a server. While those files sit on your computer, only you can see them. For anyone else to open the site, the files must live on a machine that is on all the time and reachable over the internet.

Hosting is the service that provides that machine, the network connection and the power to keep your site online. Knowing what it does helps you pick the right type and debug problems when the site goes down or slows down.

hostingBrowserDNSServerexample.com?IPGET /aboutHTTPSreads the fileor runs code200 + HTML, CSS, JSbuilds the page
DNS only gives out the address; the hosting is the server that takes the request and returns the site's files.

What is web hosting in practice?#

According to MDN, a web server is a computer running HTTP server software that understands URLs and HTTP, the protocol your browser uses. It receives a request, finds the document and sends it back. If the document does not exist, it answers with 404.

Hosting means keeping your site's files on a server like that. MDN explains why a server set aside for this beats your laptop: it is typically always connected, can have a constant IP address (not every home ISP offers one) and is usually maintained by a third party.

How does it work, from click to page?#

When you type example.com in the browser, a short sequence runs:

  1. The browser asks DNS which IP address matches the name. DNS is the system that translates names into addresses, described in RFC 1034. More in What is DNS and how does it work.
  2. The browser opens a connection to that IP, usually over HTTPS, which encrypts the traffic (SSL/TLS).
  3. It sends an HTTP request, for example GET /about.
  4. The hosting server reads the file (or runs the code that builds the page) and returns a response with a status such as 200 or 404.
  5. The browser assembles the page from the HTML, CSS and JavaScript it received.

Hosting is step 4: the machine and software that answer. The domain and DNS come before it, and the difference between them is covered in Domain vs hosting.

Static vs dynamic: what changes for hosting?#

MDN defines a static web server as one that sends its files as they are, and a dynamic web server as one that adds an application server (and usually a database) that changes the content before sending it. That difference decides what you need to buy:

Static site Dynamic site
Example Portfolio, docs, landing page Store, blog with an admin panel, social network
The server Reads and returns files Runs code and queries a database
Web server always online Yes Yes
Your code running on the server No Yes, all the time
Updating content Replace the files, live on the next request Deploy new code, usually with a restart
Minimum hosting Anything that serves files Something that runs your language and, if needed, a database

If you are just starting, MDN recommends making your first site static because it is the easiest to publish. Details in What is a static site.

What are the types of hosting?#

Names vary by company, but the models repeat:

  • Shared: many sites split one server and the provider looks after the system. It is cheap and simple, with little control and performance that depends on your neighbors.
  • VPS (virtual private server): a slice of a physical server with its own operating system and resources. You get full control and also the job of updating, securing and configuring it.
  • Dedicated server: a whole physical machine for you. More performance and cost, and the same administration work as a VPS.
  • Cloud: virtualized resources across many servers, usually billed by usage or by plan. Some services give you just the environment to run your code, with no operating system to touch.

To compare the workload of each, see VPS, cloud or hosting platform.

What should you check before choosing?#

  • Site type: static runs almost anywhere. Dynamic needs support for your language (Node.js, Python, PHP) and for a database, if you use one.
  • Resources: RAM, CPU, storage and traffic. Check whether traffic is capped or covered by a fair-use policy.
  • Server location: the closer to your visitors, the lower the latency. A CDN reduces the effect for static files.
  • Domain and HTTPS: confirm you can use your own domain and that the certificate is automatic.
  • Availability: what the provider promises and what happens when something fails.
  • How you publish: file upload, Git or a CLI. The more automated, the fewer manual mistakes.
  • Total price: include renewals, the domain and extras. See How much does website hosting cost and the checklist in How to choose a hosting provider.

When is website hosting not enough?#

Hosting built only for pages and traditional control panels often cannot run long-lived processes such as a bot, a Node.js API or a service that keeps connections open. For those you need an environment that runs your code continuously, such as a VPS or an application platform. If your project is only HTML, CSS and JavaScript in the browser, the simplest hosting is enough.

How to do this on Square Cloud#

Square Cloud is self-service hosting, so you publish the site yourself: upload a ZIP in the dashboard, use the CLI or connect GitHub. There is a runtime for static sites as well as Node.js, Python, PHP and others, so the same place works for a portfolio and for a dynamic site.

Every site gets a *.squareweb.app subdomain with HTTPS on any plan, with an automatic certificate. A custom domain is available from the Standard plan: you register the domain with your registrar and create the DNS records shown in the dashboard. The domain stays registered in your name, at your registrar.

Plans are paid, starting at R$12.49 per month on Hobby, and include traffic with no bandwidth or per-request charges (fair-use policy), a global CDN, DDoS protection and cookieless analytics. See the options in website hosting on Square Cloud.

Website hosting

Static and SSR sites with automatic TLS and a global CDN

Learn more

FAQs

Are web hosting and a domain name the same thing?

No. The domain is the address (example.com) and hosting is the server where the files live. You register the domain with a registrar and point it, through DNS, to the host's IP address.

Do I need hosting to have a website?

Yes, unless you serve the files from your own computer, which would have to stay on, be reachable by IP and be set up as a server. That is why almost everyone uses a hosting service.

What is the difference between hosting and a server?

A server is the machine (or the software) that answers requests. Hosting is the service that puts your site on a server, with network, power and, depending on the plan, system maintenance.

Can I host a website for free?

There are free offers for static sites, usually with usage limits and no support. For a serious project, check the usage terms, custom domain support and what happens when traffic grows.

How much storage and RAM does a website need?

A small static site takes a few megabytes and almost no RAM. A dynamic site with a database needs a process that is always running, and the RAM depends on the language and the traffic.

Next step · Step 2 of 5How to host a website: a beginner's guideTo host a website, build the final files, upload them to a server that stays on all the time and point an address at it. Here is the full step-by-step guide.

More in Websites

See all 20 articles