Usually a vacuum leak.
PCV hoses and intake manifold gaskets are really common sources. Could be a intake hose leak or a MAF sensor issue.
Click on SEARCH, select Troubleshooting forum, keywords "P0171 P0174", select AND, select ALL POSTS, and see the results of numerous previous discussions.
Steve