Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Logging into a remote host using ssh -X me@host, I successfully run gnome-terminal -e "tail -F /var/log/file" &. When I log off and then try the same thing the next day, I get this:

Failed to get the session bus: Failed to connect to socket /tmp/dbus-K99gT9yDjS: Connection refused Falling back to non-factory mode. Failed to summon the GConf demon; exiting. Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-K99gT9yDjS: Connection refused)

How do I run gnome-terminal in this situation?

share|improve this question
I don't see a question being asked here. You should do something about that before your post gets closed. – Agi Hammerthief Mar 20 '14 at 16:13
You might want to cut the 'solution' part out of your question and submit it as an answer. That's acceptable behaviour. – Agi Hammerthief Mar 20 '14 at 16:17
If you're logging into another machine with SSH, you'll get shell/terminal access. You don't need to open a terminal window on that machine. You can execute commands directly on that machine by typing them into the terminal on your machine. – Agi Hammerthief Mar 20 '14 at 16:21
As Nigel Nquande says, please press the answer your own question button, and copy and paste your Solution section into the answer. Not only is it acceptable, its encouraged. – derobert Mar 20 '14 at 16:38
In the meantime I have removed the solution from your question since it is not a question. This kind of self-answered question is more than welcome but please post answers as answers. Have a look at our help center or take the 10 second tour for more information. You can see the original text (so you don't need to write it out again) in the edit history which you can get to by clicking on the "Edited X min ago" link. – terdon Mar 20 '14 at 16:41
up vote 3 down vote accepted

I found this:


Which led me to try this:

$ sudo rm /var/lib/dbus/machine-id
$ sudo service messagebus restart

Now I can run gnome-terminal!

share|improve this answer
Incredibly enough, it worked also in 16.04. I just had to change the restart command to sudo service dbus restart. Thanks! – Avio Jun 20 at 13:12

Indeed when an SSH session is open, it doesn't launch a dbus session. Some programs may launch it, but then the session doesn't know about it (hence can't close it).

Not knowing about the dbus session also means that programs thzat use dbus but don't launch it themselves will have problems.

dbus sections are per machine and per X11 display. Their info is stored in $HOME/.dbus/session-bus/- however, the process referenced there may be closed, so an extra check is needed to determine if launching dbus is needed or not. Then, the variables there are to ber exported to the session.

Then it works like a charm :)

I put the following in my .bash_profile file:

# set dbus for remote SSH connections
if [ -n "$SSH_CLIENT" -a -n "$DISPLAY" ]; then
    machine_id=$(LANGUAGE=C hostnamectl|grep 'Machine ID:'| sed 's/^.*: //')
    x_display=$(echo $DISPLAY|sed 's/^.*:\([0-9]\+\)\(\.[0-9]\+\)*$/\1/')
    if [ -r "$dbus_session_file" ]; then
            export $(grep '^DBUS.*=' "$dbus_session_file")
            # check if PID still running, if not launch dbus
            ps $DBUS_SESSION_BUS_PID | tail -1 | grep dbus-daemon >& /dev/null
            [ "$?" != "0" ] && export $(dbus-launch) >& /dev/null
            export $(dbus-launch) >& /dev/null

notes: hostnamectl is part of systemd and allows to retrieve the machine-id the dbus-launch displays the variables we want; by using export $(dbus-launch) we retrieve the output of dbus-launch and export the variables

share|improve this answer

None of the previous answers worked in my case but launching the application through dbus-launch did the job:

ssh myhost "dbus-launch gnome-terminal --display localhost:10.0 &"
share|improve this answer

Try this:

rm $HOME/.dbus/session-bus/*
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.