I keep encountering this problem on my test server when I migrate data or upgrade. You fix the cookie path but then need to clean cookies on the browser side (as already suggested in comments) but also sessions and content on the server side that might remember the wrong setting. Otherwise, things remain in a mismatch and redirect hell follows.
I'm not sure if all the steps are needed each have been needed in the past so I do all of them.
Here's what I just did on a bitnami test instance with just an IP today, on 2.2.2 .
- check/change cookie domain and cookie path to match local domain or ip
- clear browser cookie
- clear magento cache and static content
- check (and fix) ownership and writeability of the various folders in /var/ as they keep being left in an odd state by the magento command line actions (probably bitnami only)
- delete content of page_cache, cache etc. if not empty
- restart browser