In my case, the problem was a missing entry in ~/.Xautority on the Linux machine. You probably shouldn't edit the file directly, but use the commandline tool xauth.
Take the display name and the id from the error message and use them in the xauth command.
Could not open display localhost:10.0
````````` ``
In my case it's localhost and 10. To add it, use the xauth add command:
xauth add localhost/unix:10 MIT-MAGIC-COOKIE-1 27e035688dd89483c6fe48b2470172f5
````````` ``
The last hex-number is 32 characters long. You can create your own (quite) random number on the Linux shell with one of these commands:
mcookie
uuidgen -r | sed s/-//g
head -c 16 /dev/urandom | xxd -p
You can check, what has been added by command xauth list.