Indiana University Bloomington

School of Informatics and Computing


Computer Science Program







 Home

 Contacts

 Courses

 Academics

 Careers

 Research

 People

 Calendar

 Resources

 Facilities
   FAQ
   System Notices
   Help
   Hardware
   Software
   Network
   Policies
   Lindley Hall

CSG FAQ

Q: Why does emacs fail when I run it remotely from my PC or Mac?

When you run 'emacs' or 'xemacs' while logged into a unix machine from your PC or Mac, it checks to see if you have the DISPLAY environment variable set. If it is, it runs as an X client and will try to display itself on the display specified in the DISPLAY environment variable. If you are on a system that is running X (ie. a unix machine or a PC running X windows software) this all works fine. However, if your machine isn't running X (ie. the typical PC or Mac) then you will get an error like this:
  emacs: Cannot connect to X server 129.79.107.54:0.
  Check the DISPLAY environment variable or use `-d'.
  Also use the `xhost' program to verify that it is set to permit
  connections from your machine.
This means that emacs was unable to connect to an X server running on the machine specified by the DISPLAY environment variable.

To correct this problem, you have several options:

  1. Ideally, you should set things up to prevent the DISPLAY from being set in the first place. The default CS configuration files you get with a new account shouldn't set the DISPLAY incorrectly but if you have old configuration files look for anything in your startup files (ie. .bashrc, .profile, .cshrc, etc) that is setting the DISPLAY environment variable improperly. You may also try using a default terminal type other than xterm. To check this, go into the properties/settings for the ssh client you are using and see if your terminal type is set to xterm and, if it is, set it to something else (vt100 should work). If you are using PuTTY, go to the Connection category and change the Terminal-type string from xterm to vt100. If you are using the SSH Communications Security ssh client, the default terminal type should already be vt100. To change or check the setting, go to Settings... under the Edit menu and check the Terminal Answerback: setting under Profile Settings/Connection.

  2. You can run 'emacs -nw' instead of just 'emacs'. The -nw flag means "no window" and should work fine in your ssh terminal window.

  3. You can unset the DISPLAY environment variable before you run emacs. You can do this with:

    If using the bash shell: unset DISPLAY

    If using the csh/tcsh shell: unsetenv DISPLAY

Another option is to run X server software on your system. If you are running Windows, see the corresponding FAQ entry for more information.



See an error in this FAQ entry? Please report it.

[Return to the FAQ index]









Valid HTML 4.01!