WordPress archive page showing 404 Error [duplicate]

You should mention register function in your Question.
Add flush_rewrite_rules( false ); in Your custom_post_type register function. it is necessary when you are creating custom post with archive.

example code:

function create_my_post_type(){
     register_post_type('MyPost', array(
                       'labels' => array('name' =>__('My-custom-Post'),'singular_name' => __('my-post')),
                         'rewrite' => array('slug' => 'MyPost','with_front' => true),
                          'public'=>true,
                          'has_archive' => true,
                       ));
      flush_rewrite_rules(false);    //recreate rewrite rules.
}

add_action('init','create_my_post_type');