How do I display post count of a custom post type with custom category taxonomy in wp_menu_nav?

Here is your solution-

add_filter( 'wp_setup_nav_menu_item','the_dramatist_item_setup' );
function the_dramatist_item_setup($item) {
    if ('taxonomy' === $item->type) {
        $posts = get_posts( array(
            'post_type'   => 'post',
            'numberposts' => -1,
            'tax_query' => array(
                array(
                    'taxonomy' => 'category',
                    'field' => 'id',
                    'terms' => $item->object_id, // Where term_id of Term 1 is "1".
                    'include_children' => false
                )
            )
        ) );

        $item->title = $item->title . '(' . count( $posts ) . ')';
    }

    return $item;
}

error code: 523