Request failed with status code 401

Describe the issue/error/question

After deploying n8n to Heroku using the click to deploy button on the eco tier for the web app I’m consistently getting the following error: Request failed with status code 401.

It continuously redirects to the “set up an owner” page, when I fill it out the workflows page just keeps on loading, when I do manage to add a workflow, the workflow gets lost and it redirects back to the “set up an owner” page. n8n is totally unusable at this stage.

I have while debugging downgraded n8n to version 0.184.0 and I’m still getting similar behavior so versioning is ruled out.

I suspect it might be database related but I am not sure. If someone could please assist that would be much appreciated.

What is the error message (if any)?

Request failed with status code 401

Information on your n8n setup

  • n8n version:0.210.1
  • Database you’re using :Postgress
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via : Heroku

Hey @JD_Oberholster,

Welcome to the community :tada:

Is there anything in the Heroku logs? It sounds like it could be a configuration thing but it is hard to say.

Hi @Jon

Thanks for the welcome, I love n8n it’s a great product.

Please see the logs below from Heroku.

2023-01-09T14:37:15.339188+00:00 heroku[router]: at=info method=GET path=“/assets/open-sans-latin-600-normal.4ffc35ac.woff2” host=xx.herokuapp.com request_id=cd51902b-43b9-4653-ad2e-9ba4f435c31a fwd=“102.66.127.231” dyno=web.1 connect=0ms service=3ms status=304 bytes=215 protocol=https

2023-01-09T14:37:15.340181+00:00 heroku[router]: at=info method=GET path=“/rest/workflows” host=xx.herokuapp.com request_id=a1650b9c-c40b-443e-98a0-4e81b92dc93f fwd=“102.66.127.231” dyno=web.1 connect=0ms service=3ms status=401 bytes=135 protocol=https

2023-01-09T14:37:15.347269+00:00 heroku[router]: at=info method=GET path=“/n8n-logo-expanded.svg” host=xx.herokuapp.com request_id=3fc98c64-81d2-4d95-9a18-cfd5a68c6455 fwd=“102.66.127.231” dyno=web.1 connect=0ms service=4ms status=304 bytes=214 protocol=https

2023-01-09T14:37:35.925461+00:00 app[web.2]: Owner was set up successfully

2023-01-09T14:37:35.937680+00:00 heroku[router]: at=info method=POST path=“/rest/owner” host=xx.herokuapp.com request_id=670c6fde-4fd3-4169-9640-aca733a83d03 fwd=“102.66.127.231” dyno=web.2 connect=0ms service=180ms status=200 bytes=1303 protocol=https

2023-01-09T14:37:36.180696+00:00 heroku[router]: at=info method=GET path=“/rest/workflows” host=xx.herokuapp.com request_id=72d62828-c39b-48a1-b116-875941dd3880 fwd=“102.66.127.231” dyno=web.1 connect=0ms service=4ms status=401 bytes=135 protocol=https

2023-01-09T14:37:36.182504+00:00 heroku[router]: at=info method=GET path=“/rest/users” host=xx.herokuapp.com request_id=185cbcd8-2237-42ec-9676-27f11bc4d8c4 fwd=“102.66.127.231” dyno=web.1 connect=0ms service=4ms status=401 bytes=135 protocol=https

2023-01-09T14:37:36.213573+00:00 heroku[router]: at=info method=GET path=“/rest/active” host=xx.herokuapp.com request_id=586b339e-8ec1-4ca9-86ef-d21ee75b7405 fwd=“102.66.127.231” dyno=web.1 connect=0ms service=4ms status=401 bytes=135 protocol=https

2023-01-09T14:37:36.218742+00:00 heroku[router]: at=info method=GET path=“/favicon.ico” host=xx.herokuapp.com request_id=53f9247e-c5b5-49c2-8f81-a8b5dfca37c3 fwd=“102.66.127.231” dyno=web.1 connect=0ms service=1ms status=304 bytes=215 protocol=https

2023-01-09T14:37:36.218864+00:00 heroku[router]: at=info method=GET path=“/assets/element-icons.ab40a589.woff” host=xx.herokuapp.com request_id=8e0998e9-1d03-414c-9741-ffd0ff1e499f fwd=“102.66.127.231” dyno=web.2 connect=0ms service=3ms status=304 bytes=215 protocol=https

Hey @JD_Oberholster,

Was there anything else? I will run through the deployment guide and the docs in about an hour or so to see if I can spot anything.

1 Like

Hi @Jon

There was nothing that stood out in the logs. The DB is looking strange though, you can see in the screenshot below, no tables or rows in the db.

I have checked the database config and the URL matches the URL in the config.

Hey @JD_Oberholster,

Just ran through it, It seems to deploy and work without issues for me at the moment but I suspect as there are missing env options to make Postgres work there will be other issues like if the instance restarts you would need to fill out the information again as the data is normally persisted in the database.

As a temporary solution if you remove…

N8N_BASIC_AUTH_ACTIVE
N8N_BASIC_AUTH_PASSWORD
N8N_BASIC_AUTH_USER

From the Environment Options then added…

DB_TYPE - postgresdb
DB_POSTGRESDB_DATABASE - found in DATABASE_URL
DB_POSTGRESDB_HOST - found in DATABASE_URL
DB_POSTGRESDB_PORT - found in DATABASE_URL
DB_POSTGRESDB_USER - found in DATABASE_URL
DB_POSTGRESDB_PASSWORD - found in DATABASE_URL
DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED - false

In DATABASE_URL the format is…

postgres://USER:[email protected]:PORT/DATABASE

This should at least help you up and running.

Hi @Jon

This worked perfectly. I can’t thank you enough. You have made my day.

Marking this as the solution.

Warm Regards
JD Oberholster

1 Like

Hey @JD_Oberholster,

I am just working on a new deployment update that should work out the extra bits, I will let you know when it is ready if you wanted to give that a test.

Hey @JD_Oberholster,

If you are interested there is a version here: GitHub - n8n-io/n8n-heroku at fix/database-args which will automatically work out the database settings as well as disable basic auth by default to make life a bit easier.

I have done a few test runs with it now and it appears to be working well so I will probably get a PR put together in the morning but figured I would let you know just incase you wanted to give it a test on a new instance.

Hey @Jon

Thanks a lot. I am going to do another installation this month and will use this version.

Appreciate the efforts!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.