Error getting OAuth access token. cURL error 7: Failed to connect
Hi,
I've set up a gitlab and nextcloud instance using docker-compose (behind a plesk proxy that redirect http to https) on my server recently and I am quite happy with them. However, I struggle a bit with the gitlab integration app in nextcloud.
Basically, I've followed the instructions and created an application on gitlab, called "Nextcloud" and with the following permissions

On nextcloud, I've filled the app ID and secret keys as informed, but when I try to connect my user, I get the following error message:
Error connecting to GitLab: Error getting OAuth access token. cURL error 7: Failed to connect to git.XXXX.com port 443: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://git.XXXX.com/oauth/token

I don't see much more information on the server logs or in the console so I'm a bit confused how to debug this issue.

As a test, I've tried manual curl calls to https://git.XXXX.com/api/v4/user in a terminal (at different locations) but get a 404 error, although I receive an response when I type this address in firefox directly. I can also see the request on the nginx logs from the gitlab docker:
192.168.128.1 - - [25/Aug/2021:22:30:12 +0000] "GET /oauth/authorize?client_id=XXX&redirect_uri=https%3A%2F%2Ffiles.XXXX.com%2Fapps%2Fintegration_gitlab%2Foauth-redirect&response_type=code&state=z160x7sz4&scope=api%20read_user%20read_api%20read_repository HTTP/1.0" 302 221 "" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0" -
Does anyone have an idea? Thank you!
Up! :)
Hi, so apparently, the server side of your Nextcloud instance can't reach your GitLab instance. It's expected to get an error when requesting /api/v4/user because the CURL request is not authenticated. You may try to reach /api/v4/projects for proper testing.
Are your Nextcloud and GitLab instances on the same machine? Could you get inside the Nextcloud server container and run the following command?
host git.XXXX.com
Your issue is very specific to your setup. I don't think I can provide much help. You'll have to investigate why the Nextcloud -> GitLab requests are failing.
Hi @eneiluj,
Thank you for your feedback!
I am indeed running the two instances on the same machine! They are simply running in different docker containers. The only "specific" configuration in my setup is the use of traefik as a reverse proxy, but in a way this is also quite common.
The result of host in the nextcloud container gives:
host git.XXX.com
git.XXX.com has address PRIVATE_IP_OF_THE_DOCKER_COTAINER
When I do the same in a shell remotely, I obtain:
host git.XXX.com
git.XXX.com has address PUBLIC_IP_OF_MY_SERVER