emacs on feora core 2

I just intall fedora core 2 but anytime i am trying to open a file using emacs  =====> emacs myfile,
i am getting the the error message below. What could i do.
===================ERROR MESSAGE ===========================
crux:/afs/clarkson.edu/class/cs242/komlaaa/hw6/cd> emacs AbstractCd.java
Xlib: connection to "localhost:11.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
emacs: Cannot connect to X server localhost:11.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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is the user you are when invoking emacs the same user that logged in? If that's not the case you'll see this error.

crux:/afs/clarkson.edu/class/cs242/komlaaa/hw6/cd> xhost +; emacs -d `echo $DISPLAY` AbstractCd.java


   Is the issue resolved?

   If you use ssh from the Fedora Core 2 (A) login to other Unix/Linux box (B) , then make sure you enable ForwardX11
--- /etc/ssh/ssh_config ---
ForwardX11 yes

and ssh into FC2 (A) from other box (B), check
--- /etc/ssh/sshd_config ---
X11Forwarding yes

  The "xhost +" is run on the machine in fromt of you.
Say you are in front of FC2 (A), before you ssh into (B), run "xhost +" on (A) first.
ssh -X <remote machine name or IP>

   Besides, remove ~/.Xauthority  at FC2 (A) and (B) then log out and log bcak in (.Xauthority will
be recreated).


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.