Guide VPS

I locked myself out with my firewall

Locked out by your firewall or a network change? Log in through the console in the client area and open up SSH again yourself.

By Hermie Updated

Can't reach your VPS over SSH anymore because your firewall or a network setting is blocking the connection? You can fix that yourself through the console in the client area. The console works as if you're sitting in front of your server's screen, so it also works when SSH is blocked.

What you need

  • Your username: debian, ubuntu, almalinux or rocky, depending on your operating system. It's also shown on the VPS card in the client area.
  • The password of that user. You received it by email after the installation.
  • Your VPS must be running.

Recover through the console

  1. Log in to the client area and go to Services.
  2. Open your VPS and click Console.
  3. Wait until the connection is established. If you see a black screen, click inside the console and press Enter; the login prompt will appear.
  4. Log in with your username and password.
  5. Open up SSH again with the command for your firewall (see below). The command starts with sudo, after which the server asks for your password once more.
  6. Click Back and log in over SSH again.

The console in the browser, with the connection status at the top and the Ctrl+Alt+Del and Back buttons

ufw

Allow SSH again:

bash
sudo ufw allow 22/tcp

If you use a different SSH port, replace 22 with that port. If you first just want to get back in, turn ufw off completely and then set it up again at your own pace:

bash
sudo ufw disable

firewalld

bash
sudo firewall-cmd --add-service=ssh --permanent && sudo firewall-cmd --reload

iptables or nftables

If you created the rules yourself with iptables or nftables, remove the rule that blocks SSH or add a rule that allows port 22. For example with iptables:

bash
sudo iptables -I INPUT -p tcp --dport 22 -j ACCEPT

A wrong network setting

If you changed the network settings, restore your old settings in the console and apply them again. Once your network works again, you can log in over SSH again too.

Lost your password as well?

Without a password you can't log in to the console. You then have two options:

  • Reinstall through the client area. You get a clean VPS with new login details.
  • Open a ticket. Mention which VPS it's about and what you changed, for example which firewall rule or network setting. If you caused it yourself, that's paid work at €30 per quarter hour excl. VAT.

Reinstalling wipes your VPS

When you reinstall, all files on your VPS are lost. If you have data you want to keep, choose a ticket.

How to prevent it

ufw

Allow SSH first and only then turn on the firewall:

  1. sudo ufw allow OpenSSH
  2. sudo ufw enable

If you use a different SSH port, allow that port instead, for example sudo ufw allow 2222/tcp.

Network settings with netplan

Use sudo netplan try instead of sudo netplan apply. With netplan try your changes are rolled back automatically if you don't confirm them within a short time. So if you lose your connection, it comes back by itself.

Windows

Always keep Remote Desktop (RDP) allowed in Windows Firewall. If you block RDP, you can no longer reach your VPS.

Keep a second session open

When you change the firewall or SSH settings, keep your current session open. Test in a second window whether you can still log in. If you can't, you can still revert it in the first session.

See also

Still stuck? Open a ticket and mention your server name.

Did this article help you?

Did not find what you were looking for?

Open a ticket and our team will look into it with you. For a quick question, Discord works too.

Open a ticket Go to Discord