In tmux session, cannot connect to X server after ssh'ing

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
8
down vote

favorite
2












At work, I have a desktop with a monitor and a few running tmux sessions. At home, I frequently ssh into that desktop and enter my running tmux sessions. When I ssh from home, I do not want to use X11, so I do not use the -X flag. When I go back to work (after ssh'ing from home) and use those tmux sessions on desktop, I can no longer do anything that would spawn a GUI. I can't open files in evince. When I try use matplotlib, I get a : cannot connect to X server message.



After ssh'ing and opening an existing tmux session from home, how do I later reattach the ability to open up GUI stuff on the desktop?



The ssh'ing from home seems to make the tmux session forget that it can spawn GUI stuff.



EDIT:










share|improve this question























  • Bit confused. Are you using the -X flag now or not? You can only do X11 stuff through SSH if that's set.
    – Anko
    Jul 25 '14 at 21:09











  • Sorry for the confusion. I never use the -X flag, anywhere. I do not intend on doing X11 stuff through SSH. I only intend on using X11 on my desktop, where the tmux session actually lives. I'll update the original question.
    – chrisdembia
    Jul 26 '14 at 23:23














up vote
8
down vote

favorite
2












At work, I have a desktop with a monitor and a few running tmux sessions. At home, I frequently ssh into that desktop and enter my running tmux sessions. When I ssh from home, I do not want to use X11, so I do not use the -X flag. When I go back to work (after ssh'ing from home) and use those tmux sessions on desktop, I can no longer do anything that would spawn a GUI. I can't open files in evince. When I try use matplotlib, I get a : cannot connect to X server message.



After ssh'ing and opening an existing tmux session from home, how do I later reattach the ability to open up GUI stuff on the desktop?



The ssh'ing from home seems to make the tmux session forget that it can spawn GUI stuff.



EDIT:










share|improve this question























  • Bit confused. Are you using the -X flag now or not? You can only do X11 stuff through SSH if that's set.
    – Anko
    Jul 25 '14 at 21:09











  • Sorry for the confusion. I never use the -X flag, anywhere. I do not intend on doing X11 stuff through SSH. I only intend on using X11 on my desktop, where the tmux session actually lives. I'll update the original question.
    – chrisdembia
    Jul 26 '14 at 23:23












up vote
8
down vote

favorite
2









up vote
8
down vote

favorite
2






2





At work, I have a desktop with a monitor and a few running tmux sessions. At home, I frequently ssh into that desktop and enter my running tmux sessions. When I ssh from home, I do not want to use X11, so I do not use the -X flag. When I go back to work (after ssh'ing from home) and use those tmux sessions on desktop, I can no longer do anything that would spawn a GUI. I can't open files in evince. When I try use matplotlib, I get a : cannot connect to X server message.



After ssh'ing and opening an existing tmux session from home, how do I later reattach the ability to open up GUI stuff on the desktop?



The ssh'ing from home seems to make the tmux session forget that it can spawn GUI stuff.



EDIT:










share|improve this question















At work, I have a desktop with a monitor and a few running tmux sessions. At home, I frequently ssh into that desktop and enter my running tmux sessions. When I ssh from home, I do not want to use X11, so I do not use the -X flag. When I go back to work (after ssh'ing from home) and use those tmux sessions on desktop, I can no longer do anything that would spawn a GUI. I can't open files in evince. When I try use matplotlib, I get a : cannot connect to X server message.



After ssh'ing and opening an existing tmux session from home, how do I later reattach the ability to open up GUI stuff on the desktop?



The ssh'ing from home seems to make the tmux session forget that it can spawn GUI stuff.



EDIT:







ssh x11 tmux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 26 '14 at 23:24

























asked Jul 25 '14 at 21:02









chrisdembia

17918




17918











  • Bit confused. Are you using the -X flag now or not? You can only do X11 stuff through SSH if that's set.
    – Anko
    Jul 25 '14 at 21:09











  • Sorry for the confusion. I never use the -X flag, anywhere. I do not intend on doing X11 stuff through SSH. I only intend on using X11 on my desktop, where the tmux session actually lives. I'll update the original question.
    – chrisdembia
    Jul 26 '14 at 23:23
















  • Bit confused. Are you using the -X flag now or not? You can only do X11 stuff through SSH if that's set.
    – Anko
    Jul 25 '14 at 21:09











  • Sorry for the confusion. I never use the -X flag, anywhere. I do not intend on doing X11 stuff through SSH. I only intend on using X11 on my desktop, where the tmux session actually lives. I'll update the original question.
    – chrisdembia
    Jul 26 '14 at 23:23















Bit confused. Are you using the -X flag now or not? You can only do X11 stuff through SSH if that's set.
– Anko
Jul 25 '14 at 21:09





Bit confused. Are you using the -X flag now or not? You can only do X11 stuff through SSH if that's set.
– Anko
Jul 25 '14 at 21:09













Sorry for the confusion. I never use the -X flag, anywhere. I do not intend on doing X11 stuff through SSH. I only intend on using X11 on my desktop, where the tmux session actually lives. I'll update the original question.
– chrisdembia
Jul 26 '14 at 23:23




Sorry for the confusion. I never use the -X flag, anywhere. I do not intend on doing X11 stuff through SSH. I only intend on using X11 on my desktop, where the tmux session actually lives. I'll update the original question.
– chrisdembia
Jul 26 '14 at 23:23










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










All I need to do is set the DISPLAY environment variable to :0.0. I think the issue was that I am using the fish shell, and I need to use the -x flag to set when doing this:



set -x DISPLAY :0.0





share|improve this answer
















  • 2




    Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there.
    – j08lue
    May 11 '15 at 8:32






  • 1




    Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick.
    – IsaacS
    May 14 '16 at 0:56











  • Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you?
    – icedwater
    Apr 26 '17 at 9:26







  • 1




    On bash, you should be able to use export DISPLAY=:0.0.
    – chrisdembia
    Jun 2 '17 at 0:48










  • I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY?
    – nealmcb
    37 mins ago


















up vote
0
down vote













I had the same issue. I normally use tmux as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set $DISPLAY. The answer by @chrisdembia works, but requires changing DISPLAY in each new window for the rest of the tmux session, which is a pain.



A permanent solution is to remove DISPLAY from the tmux update-environment variable in the tmux settings. You can see your current value with this command:



tmux show-options -g update-environment


To remove it, I added this line to my ~/.tmux.conf file, including everything but DISPLAY:



set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"


This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why DISPLAY is there by default, for a different common use case.





share




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f146631%2fin-tmux-session-cannot-connect-to-x-server-after-sshing%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    All I need to do is set the DISPLAY environment variable to :0.0. I think the issue was that I am using the fish shell, and I need to use the -x flag to set when doing this:



    set -x DISPLAY :0.0





    share|improve this answer
















    • 2




      Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there.
      – j08lue
      May 11 '15 at 8:32






    • 1




      Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick.
      – IsaacS
      May 14 '16 at 0:56











    • Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you?
      – icedwater
      Apr 26 '17 at 9:26







    • 1




      On bash, you should be able to use export DISPLAY=:0.0.
      – chrisdembia
      Jun 2 '17 at 0:48










    • I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY?
      – nealmcb
      37 mins ago















    up vote
    3
    down vote



    accepted










    All I need to do is set the DISPLAY environment variable to :0.0. I think the issue was that I am using the fish shell, and I need to use the -x flag to set when doing this:



    set -x DISPLAY :0.0





    share|improve this answer
















    • 2




      Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there.
      – j08lue
      May 11 '15 at 8:32






    • 1




      Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick.
      – IsaacS
      May 14 '16 at 0:56











    • Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you?
      – icedwater
      Apr 26 '17 at 9:26







    • 1




      On bash, you should be able to use export DISPLAY=:0.0.
      – chrisdembia
      Jun 2 '17 at 0:48










    • I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY?
      – nealmcb
      37 mins ago













    up vote
    3
    down vote



    accepted







    up vote
    3
    down vote



    accepted






    All I need to do is set the DISPLAY environment variable to :0.0. I think the issue was that I am using the fish shell, and I need to use the -x flag to set when doing this:



    set -x DISPLAY :0.0





    share|improve this answer












    All I need to do is set the DISPLAY environment variable to :0.0. I think the issue was that I am using the fish shell, and I need to use the -x flag to set when doing this:



    set -x DISPLAY :0.0






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Aug 1 '14 at 19:56









    chrisdembia

    17918




    17918







    • 2




      Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there.
      – j08lue
      May 11 '15 at 8:32






    • 1




      Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick.
      – IsaacS
      May 14 '16 at 0:56











    • Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you?
      – icedwater
      Apr 26 '17 at 9:26







    • 1




      On bash, you should be able to use export DISPLAY=:0.0.
      – chrisdembia
      Jun 2 '17 at 0:48










    • I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY?
      – nealmcb
      37 mins ago













    • 2




      Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there.
      – j08lue
      May 11 '15 at 8:32






    • 1




      Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick.
      – IsaacS
      May 14 '16 at 0:56











    • Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you?
      – icedwater
      Apr 26 '17 at 9:26







    • 1




      On bash, you should be able to use export DISPLAY=:0.0.
      – chrisdembia
      Jun 2 '17 at 0:48










    • I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY?
      – nealmcb
      37 mins ago








    2




    2




    Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there.
    – j08lue
    May 11 '15 at 8:32




    Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there.
    – j08lue
    May 11 '15 at 8:32




    1




    1




    Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick.
    – IsaacS
    May 14 '16 at 0:56





    Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick.
    – IsaacS
    May 14 '16 at 0:56













    Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you?
    – icedwater
    Apr 26 '17 at 9:26





    Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you?
    – icedwater
    Apr 26 '17 at 9:26





    1




    1




    On bash, you should be able to use export DISPLAY=:0.0.
    – chrisdembia
    Jun 2 '17 at 0:48




    On bash, you should be able to use export DISPLAY=:0.0.
    – chrisdembia
    Jun 2 '17 at 0:48












    I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY?
    – nealmcb
    37 mins ago





    I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY?
    – nealmcb
    37 mins ago













    up vote
    0
    down vote













    I had the same issue. I normally use tmux as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set $DISPLAY. The answer by @chrisdembia works, but requires changing DISPLAY in each new window for the rest of the tmux session, which is a pain.



    A permanent solution is to remove DISPLAY from the tmux update-environment variable in the tmux settings. You can see your current value with this command:



    tmux show-options -g update-environment


    To remove it, I added this line to my ~/.tmux.conf file, including everything but DISPLAY:



    set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"


    This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why DISPLAY is there by default, for a different common use case.





    share
























      up vote
      0
      down vote













      I had the same issue. I normally use tmux as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set $DISPLAY. The answer by @chrisdembia works, but requires changing DISPLAY in each new window for the rest of the tmux session, which is a pain.



      A permanent solution is to remove DISPLAY from the tmux update-environment variable in the tmux settings. You can see your current value with this command:



      tmux show-options -g update-environment


      To remove it, I added this line to my ~/.tmux.conf file, including everything but DISPLAY:



      set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"


      This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why DISPLAY is there by default, for a different common use case.





      share






















        up vote
        0
        down vote










        up vote
        0
        down vote









        I had the same issue. I normally use tmux as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set $DISPLAY. The answer by @chrisdembia works, but requires changing DISPLAY in each new window for the rest of the tmux session, which is a pain.



        A permanent solution is to remove DISPLAY from the tmux update-environment variable in the tmux settings. You can see your current value with this command:



        tmux show-options -g update-environment


        To remove it, I added this line to my ~/.tmux.conf file, including everything but DISPLAY:



        set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"


        This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why DISPLAY is there by default, for a different common use case.





        share












        I had the same issue. I normally use tmux as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set $DISPLAY. The answer by @chrisdembia works, but requires changing DISPLAY in each new window for the rest of the tmux session, which is a pain.



        A permanent solution is to remove DISPLAY from the tmux update-environment variable in the tmux settings. You can see your current value with this command:



        tmux show-options -g update-environment


        To remove it, I added this line to my ~/.tmux.conf file, including everything but DISPLAY:



        set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"


        This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why DISPLAY is there by default, for a different common use case.






        share











        share


        share










        answered 8 mins ago









        nealmcb

        283311




        283311



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f146631%2fin-tmux-session-cannot-connect-to-x-server-after-sshing%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)