Instagram OAuth "redirect_uri mismatch" on Railway PHP - Need Proxy Handling Advice

boo

Member
Consent to Access & Modify
I authorize Pabbly Support to log in to my account and make changes to the specified workflow for troubleshooting.
Hello Pabbly Community,
I am building an Instagram automation tool with Pabbly Connect and PHP, hosted on Railway. I’ve successfully received the authorization code, but I’m failing at the token exchange step.
■ The Error:
> "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request"
>
■ The Root Cause (Confirmed via Debug):
* Initial Request: Sent via https://dm-production-9567.up.railway.app/index.php
* The Issue: Since Railway uses a reverse proxy, my PHP server identifies the current protocol as http (non-SSL). Even when I hardcode the redirect_uri as https in my POST request, Meta continues to reject it as a mismatch.
■ My Question:
For those using Railway or similar proxy-based hosting for Instagram API integrations, how do you properly normalize the redirect_uri to satisfy Meta’s strict identity check? Is there a specific header (like X-Forwarded-Proto) or a Pabbly Webhook configuration that helps bridge this gap?
■ Debug Screenshots attached:
* Meta Error Message
* My internal redirect debug info
Thank you in advance!
 

Attachments

  • IMG_9686.jpeg
    IMG_9686.jpeg
    65.7 KB · Views: 9

boo

Member
Hi Arshil,

This issue is not related to a specific Pabbly workflow.

The error occurs during the Instagram (Meta) OAuth token exchange process on my PHP app hosted on Railway, before the flow reaches Pabbly.

So there is no workflow URL involved at this stage.

Please let me know if you still need anything from the Pabbly side.

Best regards,
Teru
 

Preeti Paryani

Well-known member
Staff member
Hi @boo,

Thank you for the clarification.

Since the issue is occurring during the Instagram (Meta) OAuth token exchange within your PHP application hosted on Railway — and before the request reaches Pabbly Connect — this would be outside the scope of Pabbly workflows.

The concern appears to be related to reverse proxy handling and redirect_uri normalization on your hosting environment, along with Meta’s strict redirect validation.

We would recommend reviewing your Railway proxy configuration (such as handling of X-Forwarded-Proto headers) and ensuring the exact redirect_uri used in both the authorization and token exchange steps matches what is configured in your Meta Developer App.

If you encounter any issue once the flow reaches Pabbly Connect, feel free to share the workflow URL and we’ll be happy to assist further.
 
Top