Why would this code work locally but break online?

Your first issue is the fact that you’re using query_posts. That function isn’t meant for creating new queries to the database; instead, it’s used to modify the existing global query.

Read up here and here for more information on what you can use instead.

Second, there is just some strange code in your template that, honestly, shouldn’t have worked in the first place. This line:

$args= array(
    'category_name' => $cat->slug, 
    'paged' => $paged,
    'cat' => '-12',
    'posts_per_page' => 2,
    'post__not_in' => array( $post->ID )
);

… is referencing variables that I don’t see elsewhere in your code. Namely, $cat and $post. The fact that you’re referencing $post at all tells me you either have some other query higher up in the page, or are inside another loop … in either case, calling query_posts() will definitely hurt.

Also, the minute differences between your local installation and network installation can also play a part. If you aren’t using the exact same versions of WP, PHP, MySQL, etc across both systems, strange differences like this can crop up.