HDMI port not detected on Ubuntu 18.04

The same thing happened to me but I was able to solve it. My solution was:

  1. Turn off the PC.
  2. Disconnect the HDMI cable.
  3. Turn on the PC (without HDMI).
  4. Log in.
  5. Reconnect the HDMI cable.

How can I solve my problem?

What worked for me (Lenovo thinkpad x1 Carbon, Ubuntu 18.04 LTS), is either switching the display manager back and forth between gdm3 and lightdm

sudo dpkg-reconfigure gdm3

and/or reinstalling lightdm and reconfiguring it again instead of using gdm3

sudo apt-get install --reinstall lightdm ubuntu-desktop

In case you using Nvidia graphics card the nvidia-driver could be a problem.

In my case, I've been using my Lenovo Y530(GTX 1050 ti) with Ubuntu 18.04 with nvidia-driver 415.xx which hasn't been supporting the secondary monitor through HDMI. I've tried in many ways with no luck. I finally upgraded the driver to 418.39 and the secondary monitor began to work! :)

But be careful in case you decided to go and install the driver but are not used to. There are some scenarios which can harm your system which would eventually lead you to format the system.