Pagination not working with custom post type

From WordPress Codex:

Add the $max_pages parameter to the next_posts_link() function when
querying the loop with WP_Query. To get the total amount of pages you
can use the ‘max_num_pages’ property of the custom WP_Query object.

So:

next_posts_link( __( 'Next <span class="meta-nav">&rarr;</span>', 'domain' ), $loop->max_num_pages );

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.