Cannot Connect to X Server :0.0 with a Qt Application

Cannot connect to X server :0.0 with a Qt application

The general causes for this are as follows:

  1. DISPLAY not set in the environment.

    Solution:

    export DISPLAY=:0.0
    ./myQtCmdHere

    ( This one doesn't appear to be the one at fault though, as its saying which X display its trying to connect to. Also, its not always 0.0, but most of the time it is )

  2. Non-Authorised User trying to run the X Application

    Solution ( as X owning user, ie: yourself )

    xhost +local:root   # where root is the local user you want to grant access to. 

Qt cannot connect to the server

"95.220.162.117" looks like a public European IP address. This public IP address is shared by all the computers/tablets/phones/etc. in your home/office. Think of it this way: The public IP address points to your router, not to a specific computer.

When a client sends a request to a public IP address, the router receives the request first. It is then the router's job to forward the request to the correct device... but in your case, your router doesn't know which device should receive the request!

There are two levels to making your connection work:

1. Private: Within your local network (Easier)

On your server, open your console and enter the following to find your private/local IP address:

ifconfig -a

Your local IP address is different from your public IP address. It identifies a specific computer on your local network. Make your client connect to this address, and your server should receive the request.

This only works when the client and the server are on the same local network (e.g. connected to the same router)

2. Public: Over the internet (Harder)

You need to set up Port Forwarding -- This tells your router to take requests received at port 33333 and forward them to your server.

To learn more about this topic, read up on Network Address Translation.

manage.py: cannot connect to X server

The Reason is "Xvfb"

i need to run my python program in bash shell with xvfb(X virtual frame buffer)
likewise,

ubuntu@localhost$ xvfb-run python webpage_scrapper.py http://www.google.ca/search?q=navaspot

It gives the result.

Now My requirement is i need to execute this shell command in python and waiting for tine to collect the result.I have to process the result.

Could you please suggest me for executing this command on python effectively.

CLion with WSL try to run QT application (xcb can not be loaded)

You need an X11 server. The first Google result for "WSL X11" is https://virtualizationreview.com/articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx which says:

To use WSL with graphical programs, an X server will need to be installed on the Windows 10 system and the DISPLAY variable will need to be set in Bash. Fortunately, there are many X servers that run on Windows; some of the more popular free ones are Xming, Cygwin X, and vcXsrv.

The article above also contains some more instructions on how to start an X11 server and to test that it works.

can not connect to Xserver while running python file using pyQT4 via ubuntu service


[Unit]
Description = Test
After=multi-user.target

[Service]
Type=simple
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/nvidia/.Xauthority"
ExecStart = /usr/bin/python /home/nvidia/main
Restart=on-failure

[Install]
WantedBy =graphical.target

I successfully executed GUI using systemd service using the above directive values

NS-3 - NetAnim error: qt.qpa.xcb: could not connect to display localhost:0.0

Got it solved!
What I did is:

  1. Enabled Virtualization in BIOS.
  2. Reset the WSL.
  3. Upgraded WSL1 to WSL2.
  4. Set WSL: 2 as default, <deb_pack>: 2 default.

Using WSL2 doesn't really make fuss with Qt.



Related Topics



Leave a reply



Submit