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)