question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JLinkGDBServerExe: cannot connect to X server

See original GitHub issue

I’m trying to debug a project using VS Code + WSL2 Ubuntu 20.04 LTS

The only thing I can think of is that maybe I should try uninstalling+reinstalling JLink. I remember having issues installing it and maybe I somehow broke something?

When I google search the issue, I end up here, which says it might be some sort of permissions issue: https://askubuntu.com/questions/175611/cannot-connect-to-x-server-when-running-app-with-sudo

I’m not sure what to make of the idea that it’s a permissions issue.

When I try to debug, I get this error message in the DEBUG CONSOLE:

Please check OUTPUT tab (Adapter Output) for output from /usr/bin/JLinkGDBServerExe
Launching server: "/usr/bin/JLinkGDBServerExe" "-if" "swd" "-port" "50000" "-swoport" "50001" "-telnetport" "50002" "-device" "nRF52840_xxAA"

I get this error message in the Adapter Output:

JLinkGDBServerExe: cannot connect to X server 

Here are my settings:

settings.json

{
    "cortex-debug.JLinkGDBServerPath": "/usr/bin/JLinkGDBServerExe", // Linux
    "cortex-debug.armToolchainPath": "/home/4a42/gcc-arm-none-eabi-9-2020-q2-update/bin/", // Linux
    "C_Cpp.default.cppStandard": "c++17",
    "C_Cpp.default.cStandard": "c11",
    "C_Cpp.default.intelliSenseMode": "clang-arm",
    "C_Cpp.updateChannel": "Insiders",
    "cmake.cmakePath": "/usr/local/bin/cmake", // Linux
    "cmake.configureOnOpen": false,
    "cmake.generator": "Ninja Multi-Config",
    "cmake.configureArgs": [
        "-DENABLE_CLANG_TIDY:BOOL=TRUE"
    ],
    "clang-tidy.lintOnSave": false,
    "clang-tidy.buildPath": "${workspaceFolder}/build"
}

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Debug",
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "jlink",
            "executable": "${command:cmake.launchTargetPath}",
            "cwd": "${workspaceRoot}",
            "device": "nRF52840_xxAA",
            "svdFile": "${workspaceRoot}/lib/nRF5-SDK/modules/nrfx/mdk/nrf52840.svd"
        }
    ]
}
Version: 1.51.1 (system setup)
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-10T23:34:32.027Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19041
marus25.cortex-debug v0.3.7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
haneefdmcommented, Sep 9, 2021

In the next release, there will be no more graphical display with JLink. If you want to enable it, you have to use -gui in serverArgs. It is unnatural for a command-line tool to be running a GUI as this makes many things complicated.

1reaction
hwmaiercommented, Aug 9, 2021

You can disable the progress bar and probably prevent this issue if you don’t run a GUI by passing `serverArgs": [“-nogui”] in your launch.json. That prevents the JLink DLL to show a GUI progress window.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot connect to X Server when running app with sudo
You need to allow the root user access to the X server: xhost local:root. And point the command to the right DISPLAY :...
Read more >
cannot connect to X server - message from Linux host
I can compile and run debug/release of Bullet3 AppBasicExampleGUI on Linux Ubuntu 20.04 host - if I execute it on that host, in...
Read more >
Cannot connect to X server GOOGLE COLAB - Stack Overflow
I am trying to make a prediction using Tensorflow Object Detection API on Google COLAB. Already I successfully completed the training process ...
Read more >
[SOLVED] Connecting to Remote J-Link via IP not resolving
I run the J-Link remote server on the host with the J-Link connected via USB and ... JLinkGUIServerExe: cannot connect to X server;...
Read more >
GUI cannot connect to an X Server - Arm Forge User Guide
Arm ® Forge does not open and you cannot connect to it when running on a remote server. "Map cannot connect to X...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found