Are you wondering: what is a hostname exactly, and what do you need it for? A hostname is a fundamental concept in computer networks. So what is a hostname really, and why should every internet user understand it? Whether you manage a website, configure email, or set up a server, you inevitably come into contact with hostnames. In this beginner-friendly article we explain clearly what a hostname is, how it works, and what you use it for.

What is a hostname: the basic definition

What is a hostname in simple terms? A hostname is a readable name assigned to a device (host) on a network. Instead of a hard-to-remember IP address such as 192.168.1.100, you can use a hostname like "webserver01" or "mail.company.com". Now that you know what a hostname is at the most basic level, we can make a comparison. It is similar to how you save contacts in your phone under a name instead of a phone number.

A hostname makes it possible to identify computers, servers, printers and other network devices with a name that is understandable for people. On the internet, hostnames are part of the Domain Name System (DNS), which translates these names into IP addresses.

The structure of a hostname explained

A full hostname (also called a Fully Qualified Domain Name, or FQDN) consists of several parts, separated by dots. Let us look at the structure using an example:

mail.company.com

We break this down as follows:

PartExampleExplanation
HostnamemailThe name of the specific device or service
Domain namecompanyThe name of your organisation or website
Top-Level Domain.comThe country code or generic extension
FQDN (complete)mail.company.comThe full, unique name on the internet

The difference between hostname and domain name

The terms hostname and domain name are often used interchangeably, but there is a subtle difference. The domain name is the overarching address (company.com), while the hostname denotes a specific device or service within that domain (mail.company.com, www.company.com, ftp.company.com). The domain name is therefore a part of the full hostname.

Where do you come across hostnames in practice?

Hostnames play a role in many everyday technical scenarios. Here are the most common uses:

Web hosting and servers

When you take out a web hosting plan, your server is assigned a hostname. This can be something like server1.hostingcompany.com. You use this hostname to connect to your server through FTP, SSH or the control panel.

Email configuration

When setting up your email address you need hostnames for the incoming and outgoing mail server. Typical examples are imap.provider.com for incoming mail and smtp.provider.com for outgoing mail. Without the correct hostnames your email client cannot connect.

DNS configuration

In DNS records you use hostnames to indicate which servers are responsible for your domain. MX records point to your mail server, NS records to your nameservers, and CNAME records link a hostname to another hostname.

Local networks

On your home network or office network, devices also have hostnames. Your computer has a hostname (for example DESKTOP-ABC123 on Windows), and through this name other devices on the network can find your computer without knowing the IP address.

Setting and changing a hostname

Depending on the operating system and the application, there are several ways to set or change a hostname.

Viewing and changing a hostname on Linux

On a Linux server you can look up and change the hostname through the terminal:

# View the current hostname
hostname

# Change the hostname permanently
sudo hostnamectl set-hostname newname.company.com

# Verify
hostnamectl

Do not forget to also update the /etc/hosts file so that the new hostname resolves correctly to the right IP address.

Changing a hostname on Windows

  1. Open System Properties - press Windows+Pause or go to Settings > System > About
  2. Click "Rename this PC" - here you can adjust the computer name (hostname)
  3. Enter the new name - use only letters, numbers and hyphens
  4. Restart the computer - the change takes effect after a restart

Setting a hostname for a website

To link a hostname such as www.company.com to your web server, you have to create a DNS record. You do this with the party that manages your DNS, often your domain registrar or hosting provider. Create an A record that links the hostname to the IP address of your server.

Rules for valid hostnames

Not every name is a valid hostname. There are technical rules laid down in internet standards:

  • A maximum of 253 characters - the full hostname (FQDN) may not be longer than 253 characters
  • Labels of up to 63 characters - each part between the dots may contain a maximum of 63 characters
  • Allowed characters - letters (a-z), numbers (0-9) and hyphens (-)
  • Do not start or end with a hyphen - a label may not begin or end with a dash
  • Not case-sensitive - hostnames are case-insensitive (Server1 = server1)
HostnameValid?Reason
webserver01YesLetters and numbers
mail-server.company.comYesA hyphen is allowed
-server.comNoStarts with a hyphen
server_01.comNoAn underscore is not allowed
my server.comNoSpaces are not allowed

Hostname and email: the MX record connection

One of the most important uses of hostnames is with email. When someone sends an email to info@company.com, the sending mail system needs to know which server is responsible for receiving email for company.com. This is determined by the MX record (Mail Exchange record) in DNS.

An MX record contains a hostname that points to the mail server. For example:

company.com.  MX  10  mail.company.com.
mail.company.com.  A  93.184.216.34

The first record says: "email for company.com should go to the server with hostname mail.company.com". The second record translates that hostname into an IP address. Without correctly configured hostnames you do not receive email. Want to know more about setting up email? Take a look at our guide on creating an email address.

Hostname vs. IP address: when do you use which?

In some situations you can use both a hostname and an IP address to reach a server. When do you choose which option?

When to use a hostname

  • When configuring email clients (imap.provider.com, smtp.provider.com)
  • In web browsers (www.company.com)
  • In DNS configuration in CNAME and MX records
  • For services that may change IP address

When to use an IP address

  • When troubleshooting DNS problems
  • In firewall rules and network configuration
  • When the DNS server is unreachable
  • In A records and AAAA records (these must always contain an IP)

Frequently asked questions about hostnames

Can I choose my hostname freely?

If you are wondering what a hostname is in your specific situation: on your own server or computer you can choose the local hostname freely, provided you follow the naming rules. For hostnames on the internet you have to own the associated domain and configure the DNS records correctly.

What happens if my hostname does not work?

If a hostname is not resolved (translated into an IP address), this can be due to an error in the DNS configuration, an expired domain, or DNS propagation delays. Check your DNS records and test with the command nslookup or dig.

Is "localhost" also a hostname?

Yes, localhost is a special hostname that always points to your own computer (IP address 127.0.0.1). It is widely used when developing and testing websites and applications on your own machine.

How many hostnames can I create under my domain?

There is no practical limit to the number of hostnames you can create under your domain name. Each hostname requires an associated DNS record (A, AAAA or CNAME) to function.

Every hosting provider uses hostnames for its servers and services. Here are typical examples of hostnames you come across when configuring your hosting:

ServiceTypical hostnameUsed for
FTP serverftp.yourdomain.comUploading and downloading files
IMAP serverimap.yourdomain.comFetching incoming email
SMTP serversmtp.yourdomain.comSending outgoing email
MySQL servermysql.yourdomain.com or localhostDatabase connection
cPanelcpanel.yourdomain.com or server.hosting.com:2083Hosting management

Knowing the correct hostnames is crucial when configuring your website, email and other online services. Always keep these details in a safe place, so that you have them at hand when you need to make configuration changes.

Want to know more about what a hostname is in the context of your specific hosting? Consult the documentation of your provider or contact their support department. Most providers list all required hostnames in the welcome message you receive after creating your account.

Tips for choosing good hostnames

When setting up servers and services, it is wise to think deliberately about your naming convention. Good hostnames are descriptive, consistent and easy to remember. Here are some practical tips you can apply:

  1. Be descriptive - use names that indicate the function (web01, db-primary, mail-eu) instead of random names
  2. Be consistent - use the same naming structure for all servers in your infrastructure
  3. Keep it short - long hostnames are harder to type and remember. Aim for a maximum of 15-20 characters per label
  4. Use numbering - add numbers when you have several servers with the same function (web01, web02)
  5. Avoid special characters - use only letters, numbers and hyphens for maximum compatibility
  6. Document your scheme - record your naming convention so that everyone on your team follows the same standard

Now that you know what a hostname is, you understand one of the fundamental building blocks of the internet. Hostnames make it possible to reach servers, websites and services through readable names instead of strings of numbers. Whether you configure your web hosting, set up an email address, or manage your own server, you will always deal with hostnames.

Now that you fully understand what a hostname is and how it works, remember this: a hostname is nothing more than a human-readable label for a network device. Through the DNS system this label is translated into the IP address that computers need to communicate with each other. With the correct DNS configuration and naming you ensure that your online services are reliable and findable for everyone.

What is a hostname: technical use in practice

Now that you know what a hostname is, let us look at how hostnames are used in practice when configuring servers, networks and hosting environments.

Hostnames in server configuration

When setting up a server, the hostname is one of the first settings you configure. The hostname uniquely identifies your server within the network and is used in log files, monitoring and communication between servers. A good convention for naming servers is:

  • Function-location-number - for example: web-ams-01, db-rtd-02, mail-ams-01
  • Environment as a prefix - for example: prod-web-01, staging-web-01, dev-web-01
  • Avoid creative names - names like "apollo" or "thunderbird" are fun but impractical in larger infrastructures

Hostnames in web hosting configuration

When setting up web hosting you come across hostnames in several places:

  • Email settings - the incoming and outgoing mail server (e.g. mail.yourdomain.com)
  • FTP server - the server you upload files with (e.g. ftp.yourdomain.com)
  • Database server - often "localhost" when the database runs on the same server
  • Nameservers - the DNS servers that manage your domain (e.g. ns1.hostingprovider.com)

Setting and changing a hostname

Setting or changing a hostname differs per operating system. Below are the instructions for the most common systems:

Operating systemCommandPermanent
Linux (systemd)hostnamectl set-hostname nameYes
Linux (older versions)edit /etc/hostnameYes, after reboot
WindowsSystem > About > Rename this PCYes, after restart
macOSSystem Preferences > Sharing > Computer NameYes

Common problems with hostnames

An incorrect hostname configuration can lead to various problems. Here are the most common issues and their solutions:

  • Email is rejected - if the reverse DNS (PTR record) of your mail server does not match the hostname, some mail servers reject your messages. Make sure the hostname, the A record and the PTR record are consistent.
  • SSL certificate errors - an SSL certificate is linked to a specific hostname. If your site is reachable through a different hostname than the one the certificate was issued for, visitors get a security warning.
  • DNS resolution fails - if a hostname cannot be resolved to an IP address, check whether the A record is set correctly and whether the nameservers are reachable.
  • Internal network communication fails - servers that try to reach each other by hostname need a correctly configured /etc/hosts file or a working internal DNS server.

Configuring hostnames correctly may seem like a detail, but it is fundamental to the functioning of your entire server and hosting infrastructure. Take the time to set up your hostnames consistently and logically.

Hostname and email: the crucial connection

The hostname plays a particularly important role in email delivery. Receiving mail servers check the hostname of your mail server through various mechanisms to verify that your messages are legitimate.

The PTR record (Pointer record), or reverse DNS, links an IP address back to a hostname. When your mail server sends a message, the receiving server checks whether the IP address has a valid PTR record and whether it matches the hostname in the HELO/EHLO command. If these do not match, your message may be rejected or marked as spam. Contact your hosting provider to set up a correct PTR record if you manage a mail server yourself.

The hostname of your mail server must also match your MX records and the SSL certificate. If your MX record points to mail.yourdomain.com, the SSL certificate on that server must also be valid for mail.yourdomain.com. A mismatch results in TLS errors when delivering encrypted email.

For websites, the hostname is relevant in virtual hosting, where several websites run on the same server. The web server uses the hostname in the HTTP Host header to determine which website should be shown. A wrong hostname configuration can lead to visitors seeing the wrong website or receiving an error message. This problem occurs in particular when creating subdomains if the server configuration is not updated correctly.

What is a hostname: summary and practical tips

Now that you have a complete picture of what a hostname is and how hostnames are used in practice, here is a summary of the most important points and practical tips to take with you.

A hostname is the human-readable name of a device on a network. In the context of web hosting it is the name your server is identified by, and it forms the basis of all communication: from loading websites to sending email. Always choose descriptive, consistent hostnames that reflect the function and location of the server. Avoid special characters and use only lowercase letters, numbers and hyphens in hostnames. Document all your hostnames and their associated IP addresses in a central register. After each change, test whether the hostname resolves correctly and whether all dependent services still work. With these basic principles you prevent most of the problems that can arise from an incorrect hostname configuration.

Hostname: why it matters for your online presence

Understanding what a hostname is and how hostnames work is fundamental knowledge for anyone who manages a website or offers online services. Hostnames form the bridge between the human-readable domain names and the numeric IP addresses that computers use to communicate with each other. A correctly configured hostname is essential for loading your website, delivering your email and securing your connections through SSL certificates. By naming your hostnames logically and consistently, configuring your DNS records correctly and regularly checking whether everything functions properly, you lay a solid technical foundation for your entire online presence. Take this knowledge with you when setting up new servers, configuring services and diagnosing connection problems.

Hostnames in practice: concrete examples

To make the theory about hostnames concrete, here are practical examples you can apply right away. For a web server you typically use www as the hostname, combined with your domain: www.yourdomain.com. Your mail server gets the hostname mail.yourdomain.com and your FTP server ftp.yourdomain.com. If you run several web applications, you use descriptive hostnames such as shop.yourdomain.com for your online store and blog.yourdomain.com for your blog. For internal servers that are not publicly accessible, choose names that describe the function: db01 for your first database server, backup01 for your backup server and monitor for your monitoring system. By applying these naming conventions consistently, everyone on your team immediately knows which server performs which function, and management stays clear and efficient.