# Solving X11 connection rejected problem with snap

**URL:** <https://linux-tips.com/t/solving-x11-connection-rejected-problem-with-snap/1042>\
**Category:** Shell\
**Created:** [February 17, 2023, 4:08pm UTC](https://linux-tips.com/t/solving-x11-connection-rejected-problem-with-snap/1042 "2023-02-17T16:08:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrSlump](https://linux-tips.com/user_avatar/linux-tips.com/drslump/32/61_2.png) [@DrSlump](https://linux-tips.com/u/DrSlump)\
**Post date:** [February 17, 2023, 4:08pm UTC](https://linux-tips.com/t/solving-x11-connection-rejected-problem-with-snap/1042/1 "2023-02-17T16:08:51Z")

</div>

If you have connected a remote server while SSH XForwarding enabled and try to run a X11 program which was installed with snap, you may get a X11 connection reject error like this:

```auto
$ scrcpy
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 2.7 MB/s (41159 bytes in 0.015s)
X11 connection rejected because of wrong authentication.
Segmentation fault (core dumped)

```

The solution is simple but it is hard to find it anywhere else. Just give the `XAUTHORITY` environment variable before starting the command like in the example below:

```auto
$ XAUTHORITY=~/.Xauthority scrcpy
...

```
