It appears that the pre-installed Firefox on Ubuntu 21.10 is unable to access localhost properly. Here’s the fix that I found.

The Firefox that comes pre-installed on Ubuntu 21.10 seems unable to open URLs like localhost:8000 or foo.localhost:8000. Instead of accessing the URLs, Firefox will ask you which application to use for opening this specific URL. Even if you chose Firefox as the target application, it ignores your choice and asks again.

However, localhost and 127.0.0.1 seems to work just fine. This is relevant for developers as they often run applications locally during development on a port like 8000.

After some investigation and hair-pulling, I found out that Firefox seems to even ignore the /etc/hosts file of the operating system. It then dawned on me that this may be related to snap, the new Ubuntu-specific package manager. The Firefox that ships with Ubuntu 21.10 is indeed installed as a snap package.

Snaps are isolated in their own container, the reasoning being additional security. It appears, however, that these containers are so “secure” that they are not even aware of the /etc/hosts file. This is of course a huge issue for developers.

I choose Ubuntu for the comfort it provides me when developing applications. Windows on the other hand offers a terrible, terrible developer experience for me. In my opinion, the decision by Canonical to ship Firefox as snap proves that they don’t really care about developers so much, but rather focus on gaining market share with “normal” users.

Solution

The solution turned up in a short search on how to uninstall a snap package and install Firefox from the traditional apt-get:

sudo snap remove firefox
sudo apt-get install --reinstall firefox

However, in this version, bookmarks are not show in the bookmarks bar at the top of the window. They show up in the bookmark manager, but the bookmarks bar is empty. If anyone knows how to fix this, let me know. An update to the newest version seems to have also fixed this issue.