> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Fix "Temporary Failure in Name Resolution" on Linux

> Fix "Temporary failure in name resolution" on Linux: check the network, set working DNS servers, restart systemd-resolved and add your hostname to /etc/hosts.

"Temporary failure in name resolution" means Linux couldn't turn a name such as `example.com` into an IP address. Either the server has no working network, no working DNS resolver is configured, the local resolver (systemd-resolved on Ubuntu) is stopped, or a firewall blocks DNS. Test with `ping -c 3 1.1.1.1` and `resolvectl status`, then set working DNS servers in your network configuration.

```text theme={null}
ping: example.com: Temporary failure in name resolution
Temporary failure resolving 'archive.ubuntu.com'
curl: (6) Could not resolve host: example.com
sudo: unable to resolve host web01: Temporary failure in name resolution
```

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 5 to 15 minutes | Ubuntu 22.04 / 24.04, Debian 12 / 13, AlmaLinux and Rocky Linux 9 / 10 | Root or sudo access |

## Before you start

* A **DNS resolver** is the server that answers "which IP belongs to this name?". Your server asks the resolvers in its network settings.
* If the message starts with `sudo: unable to resolve host`, jump to Cause 4 below: only your server's own name is missing.
* If SSH stopped working too, use the [VNC console](https://help.freakhosting.com/portals/vps-panel/how-to-enable-and-use-vnc-console-access.md).
* Commands use `sudo`. As root, leave it out.

## Step 1: Is it DNS or the whole network?

```bash theme={null}
ping -c 3 1.1.1.1
ping -c 3 example.com
```

| Result | Meaning |
| - | - |
| IP works, name fails | DNS problem: Causes 1 to 3 |
| Both fail | No network at all: see [SSH connection timed out, Cause 4](https://help.freakhosting.com/portals/other/how-to-fix-ssh-connection-timed-out.md) |

## Cause 1: No working DNS servers configured

An edit to Netplan, NetworkManager or `/etc/resolv.conf` can leave the server with no resolvers, or with ones that no longer answer.

**Check:**

> [tab] Ubuntu (systemd-resolved)
>
> ```bash theme={null}
> resolvectl status
> ```
>
> Each network interface should show `DNS Servers:` with at least one address. `/etc/resolv.conf` shows `nameserver 127.0.0.53`: that is the local resolver, which forwards to those servers. That line is correct; don't replace it.

> [tab] Debian / AlmaLinux / Rocky
>
> ```bash theme={null}
> cat /etc/resolv.conf
> ```
>
> You need at least one `nameserver` line with a reachable resolver.

**Fix:** set resolvers where your network tool stores them, for example `1.1.1.1` and `9.9.9.9`. On Ubuntu that is the `nameservers` block in Netplan, on AlmaLinux and Rocky it is NetworkManager. Step-by-step instructions for each system are in [change DNS resolvers on Linux](https://help.freakhosting.com/portals/other/how-to-change-dns-resolvers-on-linux.md). The [VPS Panel DNS resolver setting](https://help.freakhosting.com/portals/vps-panel/how-to-change-ipv4-public-dns-resolvers.md) only takes effect if your server uses the panel's network configuration.

## Cause 2: systemd-resolved is stopped (Ubuntu)

If `/etc/resolv.conf` points to `127.0.0.53` but the service behind it doesn't run, every lookup fails.

**Check:**

```bash theme={null}
systemctl status systemd-resolved
```

**Fix:**

```bash theme={null}
sudo systemctl enable --now systemd-resolved
```

If you replaced `/etc/resolv.conf` with your own file and then stopped the service, either keep your file and leave the service off, or restore the link:

```bash theme={null}
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
```

## Cause 3: A firewall blocks outgoing DNS

DNS uses port `53` over UDP and TCP. If you set your firewall to deny outgoing traffic, lookups fail.

**Check:**

> [tab] Ubuntu / Debian (UFW)
>
> ```bash theme={null}
> sudo ufw status verbose
> ```
>
> `Default: deny (incoming), allow (outgoing)` is normal. `deny (outgoing)` needs an exception for DNS.

> [tab] AlmaLinux / Rocky (firewalld)
>
> firewalld zones filter incoming traffic, so outgoing DNS works unless you added outbound policies or rules. List everything that is loaded with `sudo nft list ruleset`.

**Fix** (UFW with outgoing denied):

```bash theme={null}
sudo ufw allow out 53
```

## Cause 4: Your own hostname isn't in /etc/hosts

After you [change the hostname](https://help.freakhosting.com/portals/other/how-to-change-the-hostname-on-linux.md), `sudo` prints `unable to resolve host` before it runs your command. Only the server's own name is missing.

**Check:**

```bash theme={null}
hostname
cat /etc/hosts
```

**Fix:** add the hostname to `/etc/hosts`. On Ubuntu and Debian, use `127.0.1.1`:

```text theme={null}
127.0.0.1   localhost
127.0.1.1   web01
```

Replace `web01` with the output of `hostname`. The change works immediately.

## How to check it worked

```bash theme={null}
getent hosts example.com
```

An IP address followed by the name means lookups work. On Ubuntu, `resolvectl query example.com` also shows which server answered.

## Frequently asked questions

### Why is it called "temporary" if it never fixes itself?

It is the standard text for the `EAI_AGAIN` error, which the resolver library returns when no DNS server gave an answer and a retry might work. It doesn't mean the problem will go away on its own.

### Can I just edit /etc/resolv.conf?

On Ubuntu, systemd-resolved or Netplan overwrites it. On AlmaLinux and Rocky, NetworkManager does. Make the change in the tool that owns the file, as in Cause 1.

### Apt says "Temporary failure resolving". Is the mirror down?

Usually not. That message comes from your server's DNS, not the mirror. Fix DNS first, then see [apt and dnf repository errors](https://help.freakhosting.com/portals/other/how-to-fix-apt-and-dnf-repository-errors.md) if `apt update` still fails.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Change DNS resolvers](https://help.freakhosting.com/portals/other/how-to-change-dns-resolvers-on-linux.md)
>
> Set resolvers on every distribution.

> [card] [Static IP with Netplan](https://help.freakhosting.com/portals/other/how-to-configure-a-static-ip-with-netplan.md)
>
> Fix a broken Ubuntu network config.

> [card] [Change the hostname](https://help.freakhosting.com/portals/other/how-to-change-the-hostname-on-linux.md)
>
> Rename the server and update /etc/hosts.

> [card] [apt and dnf repository errors](https://help.freakhosting.com/portals/other/how-to-fix-apt-and-dnf-repository-errors.md)
>
> When package updates fail.

***

> [!NOTE]
>
> **Checked against the official systemd [resolvectl](https://www.freedesktop.org/software/systemd/man/latest/resolvectl.html) and [systemd-resolved](https://www.freedesktop.org/software/systemd/man/latest/systemd-resolved.service.html) manuals and the [Ubuntu Server networking guide](https://ubuntu.com/server/docs/explanation/networking/configuring-networks/)** on 4 November 2026; the `ping`, `curl`, `apt` and `sudo` errors and the `/etc/hosts` fix were reproduced with an empty resolver configuration on Ubuntu 24.04 LTS. Service restarts and the firewalld check were not tested.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.