Software⏱️ 4 min read📅 2026-06-19

How to Fix: VNC error: "Could not connect to session bus: Failed to connect to socket"

VNC connection error: Could not connect to session bus: Failed to connect to socket.

Quick Answer: Check the gnome-session logs for errors related to dbus connections, and try restarting the vncserver or gnome-session service.

The VNC error 'Could not connect to session bus: Failed to connect to socket' occurs when you try to connect to a VNC server on Ubuntu, resulting in a grey X window with an error message. This issue affects users who have started a vncserver on display :1 and are trying to connect to it using a VNC client.

This error can be frustrating because it prevents you from accessing the remote desktop session. However, by following the steps outlined below, you should be able to resolve the issue and regain access to your remote desktop.

⚠️ Common Causes

  • The primary reason for this error is a missing or corrupted gnome-session database file. The gnome-session daemon uses this file to store information about the session, including the DISPLAY environment variable. If the file is missing or corrupted, the daemon will fail to connect to the socket, resulting in the 'Could not connect to session bus: Failed to connect to socket' error.
  • An alternative reason for this error could be a firewall or network configuration issue that prevents the gnome-session daemon from connecting to the socket. This might occur if the daemon is unable to establish a connection to the DISPLAY environment variable, which is required for the session to function properly.

🔧 Proven Troubleshooting Steps

Enable gnome-session and update the SecurityPolicy

  1. Step 1: To resolve this issue, you need to enable the gnome-session service. This can be done by running the following command: sudo systemctl enable gnome-session.
  2. Step 2: Next, you need to update the SecurityPolicy file. You can do this by running the following command: sudo cp /etc/X11/xserver/SecurityPolicy /etc/X11/xserver/SecurityPolicy.backup.
  3. Step 3: Then, edit the SecurityPolicy file using a text editor and add the following lines at the end of the file: XorgConfig = '/usr/lib/X11/xorg.conf', XorgConfigSecurity = '/usr/lib/X11/xorg.conf.security'. Save and close the file. Finally, restart the X server by running the command: sudo service xserver restart.

Disable gnome-session or use a different VNC client

  1. Step 1: As an alternative fix, you can disable the gnome-session service to prevent the error from occurring. This can be done by running the following command: sudo systemctl disable gnome-session.
  2. Step 2: Alternatively, you can try using a different VNC client that does not rely on the gnome-session daemon for connection. Some popular alternatives include TightVNC, UltraVNC, and RealVNC.

💡 Conclusion

By enabling the gnome-session service and updating the SecurityPolicy file, or by disabling gnome-session or using a different VNC client, you should be able to resolve the 'Could not connect to session bus: Failed to connect to socket' error and regain access to your remote desktop. If you are still experiencing issues, it may be helpful to consult the VNC documentation or seek assistance from a system administrator.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions