---
title: Flask integration guide
description: Set up Flask error tracking, performance monitoring, and observability with Honeybadger in 5 minutes.
url: https://docs.honeybadger.io/lib/python/integrations/flask/
---

**Typical installation time:** 5 minutes

Hi there! You’ve found Honeybadger’s guide to **Flask error tracking and performance monitoring**. Once installed, Honeybadger will automatically report errors and performance insights from your Flask application.

## Installing the package

Install the `honeybadger` Python package with pip (or add it to your `requirements.txt`):

```bash
pip install honeybadger
```

Flask also requires the `blinker` library for automatic error reporting:

```bash
pip install blinker
```

In your Flask application, initialize the Honeybadger extension:

```python
from flask import Flask
from honeybadger.contrib import FlaskHoneybadger


app = Flask(__name__)
app.config['HONEYBADGER_ENVIRONMENT'] = 'production'
app.config['HONEYBADGER_API_KEY'] = 'PROJECT_API_KEY'
app.config['HONEYBADGER_INSIGHTS_ENABLED'] = True
FlaskHoneybadger(app, report_exceptions=True, reset_context_after_request=True)
```

Tip

`FlaskHoneybadger` checks Flask’s configuration object and automatically configures Honeybadger using [12-factor style config options](https://docs.honeybadger.io/lib/python/reference/configuration/#twelve-factor-configuration). You can also configure Honeybadger with environment variables:

```sh
export HONEYBADGER_ENVIRONMENT="production"
export HONEYBADGER_API_KEY="PROJECT_API_KEY"
export HONEYBADGER_INSIGHTS_ENABLED=True
```

If you use this method, you can omit the `app.config` settings. Environment variables take precedence over Flask configuration settings when both are present.

See the [Configuration reference](https://docs.honeybadger.io/lib/python/reference/configuration/) for additional info.

## Testing your installation

Note

Honeybadger does not report errors in `development` and `test` environments by default. To enable reporting in development environments, temporarily add `app.config['HONEYBADGER_FORCE_REPORT_DATA'] = True` to your Flask config.

To test that Honeybadger is working, you can create a simple test exception:

```python
from honeybadger import honeybadger


try:
    raise Exception("Honeybadger test exception")
except Exception as e:
    honeybadger.notify(e)
```

If the installation is working correctly, this error should appear in your Honeybadger dashboard.

## How it works

The `FlaskHoneybadger` extension uses Flask’s signals (via [Blinker](https://github.com/pallets-eco/blinker)) to detect and report exceptions. When an exception occurs, it automatically adds the following information to the error report:

* **URL**: The URL the request was sent to
* **Component**: The module that the view is defined in (or class name for class-based views)
* **Action**: The name of the function called (prefixed with blueprint name if applicable)
* **Params**: Query parameters and form data (filtered for sensitive data)
* **Session**: Session data
* **CGI data**: Request headers and method (filtered for sensitive data)

### Component naming conventions

The following conventions are used for component names:

* View functions: `<module name>#<view name>`
* Class-based views: `<module name>#<class name>`
* Blueprints: `<module name>#<blueprint name>.<view name>`

### Additional configuration options

When initializing `FlaskHoneybadger`, you can pass additional options:

| Name                          | Type   | Default | Description                                                                                            |
| ----------------------------- | ------ | ------- | ------------------------------------------------------------------------------------------------------ |
| `report_exceptions`           | `bool` | `False` | Automatically report exceptions raised in views (including those from `abort()`)                       |
| `reset_context_after_request` | `bool` | `False` | Reset [Honeybadger context](https://docs.honeybadger.io/lib/python/errors/context/) after each request |

## Sending logs from your infrastructure

Honeybadger isn’t just for errors and application data! You can use our [syslog](https://docs.honeybadger.io/guides/insights/integrations/systemd/), [Vector](https://docs.honeybadger.io/guides/insights/integrations/log-files/), or [PaaS integrations](https://docs.honeybadger.io/guides/insights/#adding-data-from-other-sources) to send additional data from your infrastructure to [Honeybadger Insights](https://docs.honeybadger.io/guides/insights/), where you can query, visualize, and analyze all of your production data in one place.

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
