xterm: Xt error: Can't open display: localhost

Dear Experts,


I am unable to open anything from remote server. I am getting this kind of error message from the server.

--------------------------

connect localhost port 6011: Connection refused


xterm: Xt error: Can't open display: localhost:12.0

--------------------


After trying so many options available on internet including "reconnect with ssh -Y, enabling X11Forwarding", I could not resolved this issue.


Also, If I tried "xhost+" in my local computer, then I got below message

-----

xhost:  unable to open display "localhost:11.0"

----


I need urgent help to resolve this issue.


My laptop details are

MacOS Ventura 13.3.1

Apple M1 Pro


Do you have any suggestion in this regard? Kindly let me know.


Regards,

Baidyanath

MacBook Pro 14″, macOS 13.3

Posted on Apr 25, 2023 4:19 AM

Reply
Question marked as Top-ranking reply

Posted on Apr 27, 2023 8:33 AM

This is what your macOS DISPLAY environment variable should look like. The hFmzPYzDYa will be different for you, but the pattern should be the same. This is generated by XQuartz. You NEVER EVERY set DISPLAY yourself:


macOS> printenv DISPLAY
/private/tmp/com.apple.launchd.hFmzPYzDYA/org.xquartz:0

ls -l $DISPLAY
srw-rw-rw- 1 raharris 0 Apr 15 12:10 /private/tmp/com.apple.launchd.hFmzPYzDYA/org.xquartz:0


The leading 's' means it is a network 'socket'


What you showed me should NOT be the macOS DISPLAY environment value. It would be correct for Linux after doing ssh -Y


Your Linux DISPLAY environment variable should look similar to this:


macOS> ssh -Y user@remote.linux.system
...
Linux> printenv DISPLAY
localhost:10.0


The localhost:10.0 may be localhost:11.0, or localhost:12.0, etc...


If your macOS DISPLAY environment variable is really localhost:11.0, then either you are unintentionally setting the environment variable manually, or in your shell initialization scripts.


When using XQuartz and ssh -Y, you should never need to manually set the DISPLAY environment variable, as XQuartz will set it on the Mac, and the ssh -Y will set it on the Linux system.

11 replies
Question marked as Top-ranking reply

Apr 27, 2023 8:33 AM in response to sbaidyan

This is what your macOS DISPLAY environment variable should look like. The hFmzPYzDYa will be different for you, but the pattern should be the same. This is generated by XQuartz. You NEVER EVERY set DISPLAY yourself:


macOS> printenv DISPLAY
/private/tmp/com.apple.launchd.hFmzPYzDYA/org.xquartz:0

ls -l $DISPLAY
srw-rw-rw- 1 raharris 0 Apr 15 12:10 /private/tmp/com.apple.launchd.hFmzPYzDYA/org.xquartz:0


The leading 's' means it is a network 'socket'


What you showed me should NOT be the macOS DISPLAY environment value. It would be correct for Linux after doing ssh -Y


Your Linux DISPLAY environment variable should look similar to this:


macOS> ssh -Y user@remote.linux.system
...
Linux> printenv DISPLAY
localhost:10.0


The localhost:10.0 may be localhost:11.0, or localhost:12.0, etc...


If your macOS DISPLAY environment variable is really localhost:11.0, then either you are unintentionally setting the environment variable manually, or in your shell initialization scripts.


When using XQuartz and ssh -Y, you should never need to manually set the DISPLAY environment variable, as XQuartz will set it on the Mac, and the ssh -Y will set it on the Linux system.

Apr 25, 2023 5:40 AM in response to sbaidyan

Have you installed XQuartz?

https://www.xquartz.org/


Did you reboot after installing, so that XQuartz sets up all the necessary hooks in your macOS login session?


When you ssh -Y user@remote.linux.system does the DISPLAY environment variable look similar to localhost:10.0 ?


when using ssh -Y, you DO NOT need host+, and if anything, host+ might interfere.


Just to be sure, did your remote login shell scripts set its own DISPLAY environment variable. It is something I would associate with using host+, and counter productive to using ssh -Y


Have you tried something simply, such xclock?


Finally, why are you using xterm, when you have a very good terminal emulator in Applications-> Utilities-> Terminal, or the open source iTerm2, which run native on the Mac?

Apr 25, 2023 12:09 PM in response to sbaidyan

On your Mac, can you run

/opt/X11/bin/xclock


This should verify XQuartz is installed and running locally.


I cannot imagine why you would be prevented from opening a localhost port.


using

lsof -i -P

on both my Mac and my remote Linux system (~2000 miles remote), my Linux system showed

xtrem … TCP localhost:35068->localhost:6010 (ESTABLISHED)


So I assume your port 6011 is on the Linux system.


I do not know what is blocking your connection.


Do you have anti-virus software running on your Mac or Linux ?


Or maybe LittleSnitch.


I’ve seen both A/V and LittleSnitch interfere with network connections.

Apr 25, 2023 12:30 PM in response to sbaidyan

If you cannot get X11 working back to your Mac, you could always install TigerVNC (or RealVNC viewer) and setup a VNC session to the remote system.


I recommend TigerVNC as it seems to have the best Copy&Paste between Linux and the Mac (should be running vncconfig on the Linux system to wire the paste buffer into VNC).


RealVNC viewer (free download) also works, and it even has a config setting to adapt for the Mac not normally having a middle mouse button.

Apr 26, 2023 6:37 AM in response to sbaidyan

If you are getting this error from your Mac


(base) baidya1@baidya ~ % /opt/X11/bin/xclock

Error: Can't open display: localhost:11.0


then, XQuartz is has not hooked into your Mac login session.


On the Mac,


printenv DISPLAY


should show a /tmp/path/to/a/FIFO file. A FIFO is a named network pipe.


NOTE: I’ve been using X11 on Macs since Apple released its own X11 app called MacX back in the late 1980’s for a version of Mac OS Classic. And the rewritten X11.app for Mac OS X in the early 2000’s. X11.app was open sourced and turned in to the XQuartz project.


I have never experienced what you are seeing. And I am currently using XQuartz on Monterey.


I do not use it as much these days, as most of my Linux hosted development and test systems are 2,000+ miles away, and the network latency is brutal on some X11 based apps that send a lot of little X11 messages to draw the display and menus. Gvim and gvimdiff are OK, but some of the other X11 apps are extremely slow.

Apr 25, 2023 11:01 AM in response to BobHarris

Hi BobHarris,


Please find my answers as mentioned below.


Have you installed XQuartz?

https://www.xquartz.org/

Ans: Yes, my XQuartz version is "XQuartz 2.8.5 (xorg-server 21.1.6)"


Did you reboot after installing, so that XQuartz sets up all the necessary hooks in your macOS login session?

Ans: Yes

When you ssh -Y user@remote.linux.system does the DISPLAY environment variable look similar to localhost:10.0 ?

Ans: Yes, I am getting below error

---------

connect localhost port 6011: Connection refused


xterm: Xt error: Can't open display: localhost:12.0

---------

when using ssh -Y, you DO NOT need host+, and if anything, host+ might interfere.


Just to be sure, did your remote login shell scripts set its own DISPLAY environment variable. It is something I would associate with using host+, and counter productive to using ssh -Y


Have you tried something simply, such xclock?

Ans: Yes, I tried xterm.


Finally, why are you using xterm, when you have a very good terminal emulator in Applications-> Utilities-> Terminal, or the open source iTerm2, which run native on the Mac?

Ans: just for checking purpose. Our server doesn't recognize "xclock".



Thanks again for your time and information.


Regards,

Baidyanath


Apr 26, 2023 12:13 AM in response to BobHarris

Hi BobHarris,


Thanks again for your responses. Please find my answers below.


On your Mac, can you run

/opt/X11/bin/xclock

Ans: I am getting bellow error on my Mac

----------

(base) baidya1@baidya ~ % /opt/X11/bin/xclock

Error: Can't open display: localhost:11.0

---------------


using

lsof -i -P

on both my Mac and my remote Linux system (~2000 miles remote), my Linux system showed

xtrem … TCP localhost:35068->localhost:6010 (ESTABLISHED)

Ans: I am getting on my remote server (CentOs 7)

-----------

sshd ..... TCP localhost:6022 (LISTEN)

-----------



So I assume your port 6011 is on the Linux system.

Ans: Yes


Do you have anti-virus software running on your Mac or Linux ?

Ans: No


Or maybe LittleSnitch.

Ans: No


Thanks again!


Regards,

Baidyanath

Nov 24, 2023 9:12 PM in response to BobHarris

I have the same problem --

Recently upgaded my Apple MacBook Air M1 from its earlier Ventura OS to Sonoma 14.1.1 OS (I should have not done this and stayed back to Ventura which was working great -- Apple should not ask for any upgrades till

its fully tested!!)


Not the xterm is not working -- its says:


--------

xterm: Xt error: Can't open display: /private/tmp/com.apple.launchd.8Zi1vl29Ju/org.xquartz:0

--------


However


xinit works and a xterm type window opens via Xquartz and in this window

xclock works


Any solution to this please??


Thanks

Ranjan

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

xterm: Xt error: Can't open display: localhost

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.