Go to Settings > Permalinks, and simply click on Save Changes button.
This will update your permalinks settings and flush rewrite rules. In most cases this solution fixes the portfolio 404 error.