DEV Community

The Witcher
The Witcher

Posted on

🌐 Remote Debugging with IntelliJ IDEA

Welcome to the world of Remote Debugging in IntelliJ IDEA! Ever wanted to squash bugs on a remote server with the finesse of your local environment? This guide has got you covered. Let’s set up remote debugging with just a few easy steps! 🚀


📋 Prerequisites

Before we dive in, make sure you have:

  1. IntelliJ IDEA installed (Ultimate version recommended for full remote debugging support).
  2. Access to your Remote Server with SSH credentials.
  3. Java application you want to debug remotely.

🛠️ Step 1: Enable Debugging on the Remote Server

First, let’s prepare your remote server to listen for incoming debugging sessions.

  1. Locate your application’s startup command (usually a java command).
  2. Add these JVM options to enable remote debugging:

    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=<PORT>
    

Replace <PORT> with your desired debugging port, such as 5005. Here’s an example:

```shell
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar yourApp.jar
```
Enter fullscreen mode Exit fullscreen mode
  1. Start your application. It’s now waiting for IntelliJ to connect. 🛰️

Note: If you are deploying the app in a server then ensure that you add the command to open a port for debugging.


🧩 Step 2: Configure IntelliJ for Remote Debugging

Now, let’s set up IntelliJ to connect to your server.

  1. Open IntelliJ IDEA and go to Run > Edit Configurations.
  2. Click + and select Remote.
  3. Enter a name for this configuration (e.g., "Remote Debugging on Server").
  4. Configure the connection details:
    • Host: IP address or domain name of your remote server.
    • Port: Same port you specified in Step 1 (e.g., 5005).
  5. Click Apply and then OK.

🚀 Step 3: Start Debugging

Ready to squash those remote bugs?

  1. Set breakpoints in your code.
  2. In IntelliJ, select your new Remote Debugging Configuration from the Run/Debug Configurations dropdown.
  3. Click on the Debug icon 🐞.

IntelliJ will connect to your remote application, and any breakpoints you set will pause the remote execution, allowing you to inspect variables, step through code, and more—just as if you were debugging locally!


⚠️ Troubleshooting Tips

  • Connection Refused? Ensure the remote server's firewall allows traffic on your debugging port.
  • Can't Reach the Server? Verify SSH access and server IP.
  • Still not working? Make sure you added the debugging JVM options correctly.

🎉 You Did It!

You’re now fully equipped to handle remote debugging like a pro! Happy debugging, and may all your bugs be minor! 🐛🚫

Top comments (0)