Tuesday, 4 December 2012

How to fix "Cannot establish any listening sockets - Make sure an X server isn't already running" error in linux

Today I had a problem. I have allocated around 30 GB of hard disk for my elementary os installation. It was almost full and only around 110 MB free space was there. But I had run the software update and shut down the computer. But after some time, when I restarted the computer, I was not able to access the Graphical User Interface. I am stuck.

Then I tried accessing the another terminal (not GUI, but tty) using key shortcut Ctrl+Alt+F1 I was able to access the terminal. I gave my username and password and I was able to login to the terminal. Then only thing not working is GUI (Hint :- issue with X windows system). I ran the command df -h and found that / is full (there is no free space).

[email protected]:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        32G   30G   0    100% /
udev            993M  4.0K  993M   1% /dev
tmpfs           401M  840K  401M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none           1003M   80K 1003M   1% /run/shm

I have run sudo apt-get autoclean and freed up some space. Also deleted some unwanted files from the computer and made enough free space. I was sure that the issue was due to the disk space full. Then I tried accessing the GUI using Ctrl+Alt+F7 (default keyboard shortcut for GUI session in Linux) but still not working. I ran sudo startx  to manually start X window manager but it didn't start and also met with below error. 


[   237.199] _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed

[   237.202] _XSERVTransMakeAllCOTSServerListeners: server already running

[   237.212] 
Fatal server error:
[   237.213] Cannot establish any listening sockets - Make sure an X server isn't already running
[   237.226] 
Please consult the The X.Org Foundation support 
at http://wiki.x.org
 for help. 
[   237.229] Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[   237.231] 
[   237.234]  ddxSigGiveUp: Closing log
[   237.237] Server terminated with error (1). Closing log file.

I then tried removing X0-lock file at /tmp/

sudo rm -r /tmp/.X0-lock 

But still it X window session is not starting. I restarted the computer and tried again. This time I was able to access the LightDM and I selected my username and entered my password. The screen blinked and I was logged out immediately from the GUI. So I was clear that the first issue where I was not even able to access the Light DM login screen was due to the disk space full issue (there was no free space, not even a 0Kb for /) and I was fixed by clearing some old files. Now this new issue is due to X windows session files.

Then again I accessed the terminal session using Ctrl+Alt+F1 and logged in to the os. Then I found that there is a hidden file Xauthority in my home directory. There was no content in it. So I removed it.

sudo rm -r /home/sree/.Xauthority

I access the GUI using Ctrl+Alt+F7 and selected my username and entered my password. This time I was able to login to my computer as a regular session and everything was working fine. So the issue was with Xauthority file (The issue may be due to the X window session which does not start properly when we tried when there was no free space) in my home directory and removing it has fixed the issue.

Solution: Just remove the .Xauthority file in your home screen. Now you will be able to login to the GUI.

Please let me know in the comments if this has worked for you also.

No comments:

Post a Comment