---
title: Disable the APM agent
source: https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/disable-apm-agent
---

You may want to temporarily disable an APM agent for the purposes of testing or troubleshooting. This document explains procedures for temporarily turning off the APM agent.

Related procedures:

-   To permanently disable APM, [uninstall the agent](https://docs.newrelic.com/docs/agents/manage-apm-agents/installation/uninstall-agent).
-   To configure an agent to monitor some things but not others, use [custom instrumentation](https://docs.newrelic.com/docs/apm/agents/manage-apm-agents/agent-data/custom-instrumentation/).

## Disable or turn off the APM agent [#agents]

Select your agent type for instructions:

**Go**

There are two main ways to disable the Go agent:

-   Remove the import of the `github.com/newrelic/go-agent` package from your application, and remove or comment out any calls to the `newrelic` namespace. Then, recompile and restart your app.
-   Use the [`enabled`](https://docs.newrelic.com/docs/agents/go-agent/configuration/go-agent-configuration#enabled) configuration setting. Then, recompile and restart your app. (This will **not** reduce overhead because the instrumentation is still running; it will only prevent the sending of data to the [New Relic collector](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/glossary#collector).)

    > #### 💡 TIP
    >
    > After you disable the agent, it may take several minutes for data to stop showing up.

**Java**

There are three main ways to disable the Java agent:

-   Set [`agent_enabled`](https://docs.newrelic.com/docs/agents/java-agent/configuration/java-agent-configuration-config-file#cfg-agent_enabled) to `false`, then restart the JVM.
-   Use the JVM command line flag:

    ```ini
    -Dnewrelic.config.agent_enabled=false
    ```

    Then restart the JVM.
-   Remove the `newrelic.jar` or `newrelic.yml` file, then restart the JVM.

    > #### 💡 TIP
    >
    > After you disable the agent, it may take several minutes for data to stop showing up.

**.NET**

The method to disable the agent depends on if you are using Framework or Core:

-   .NET Framework: Set [`agentEnabled`](https://docs.newrelic.com/docs/agents/net-agent/configuration/net-agent-configuration#config-agentEnabled) to `false` in the global `newrelic.config` file, found in `C:\ProgramData\New Relic\.NET Agent\`. If the application is IIS-hosted, restart IIS. If it's self-hosted (non-IIS), restart the application.
-   .NET Core: Set [`agentEnabled`](https://docs.newrelic.com/docs/agents/net-agent/configuration/net-agent-configuration#config-agentEnabled) to `false` in the `newrelic.config` file found in the Core agent’s installation directory (for Windows alongside `NewRelic.Profiler.dll` and for Linux alongside `NewRelic.Profiler.so`). If you use the ASP.NET Core Module, reset IIS. Otherwise, restart your Core application.

    > #### 💡 TIP
    >
    > After you disable the agent, it may take several minutes for data to stop showing up.

**Node.js**

There are two main ways to disable the Node.js agent:

-   Set [`agent_enabled`](https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration#enabled) to `false` in your agent config file, then restart the app server.
-   Set the [`NEW_RELIC_ENABLED`](https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration#enabled) environment variable to `false`.

    > #### 💡 TIP
    >
    > After you disable the agent, it may take several minutes for data to stop showing up.

**PHP**

To disable the PHP agent, set the [`newrelic.enabled`](https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration#inivar-enabled) config setting to `false`, then restart the web server or PHP.

> #### 💡 TIP
>
> After you disable the agent, it may take several minutes for data to stop showing up.

**Python**

There are three main ways to disable the Python agent, depending on your preference and setup:

-   [Standard install](https://docs.newrelic.com/docs/agents/python-agent/installation/standard-python-agent-install#install): Use the [`monitor_mode`](https://docs.newrelic.com/docs/agents/python-agent/configuration/python-agent-configuration#monitor_mode) configuration setting. This can be done by editing the config file or by using an [environment variable](https://docs.newrelic.com/docs/agents/python-agent/configuration/python-agent-configuration#environment-variables).
-   Standard install with `newrelic-admin` script: Remove reference to that script in your application.
-   [Manual instrumentation](https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-integration#manual-integration): Remove the initialization script from your application.

    > #### 💡 TIP
    >
    > After you disable the agent, it may take several minutes for data to stop showing up.

**Ruby**

There are several ways to disable the Ruby agent, depending on your preference and setup.

These methods will remove most instrumentation but there will still be a small amount of activity and overhead:

-   Use the [`agent_enabled`](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration#agent_enabled) configuration setting. This can be done in the configuration file or in the per-environment sections. Restart your app server afterward.

-   Do the same via an [environment variable](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration#Options), then restart the app server.

    The following methods will remove all instrumentation and overhead:

-   Remove `newrelic_rpm` from the Gemfile and bundle install.

-   Set the following in the Gemfile and bundle install:

    ```ruby
    gem 'newrelic_rpm', :require => false
    ```

    This option ensures the gem is installed if it's required somewhere in the app, but doesn't install it when bundling.

    > #### 💡 TIP
    >
    > After you disable the agent, it may take several minutes for data to stop showing up.
