URL Shortener times out

My URL shortener seems to be working fine EXCEPT:

  1. I get this error in the log:

(node:12679) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]

  1. When I try to follow the shortened link to the website, I get a 504 Gateway Time-out

I’ve double checked variables and connections between mLab and Glitch, but I can’t find my error.

Here’s a link to the Glitch: https://mbabaian-short.glitch.me/
And to my code: https://github.com/mbabaian/url-shortener

If somebody can help me sort this out, I’d really appreciate it. I’m almost done with this one.

TIA

How are you passing the MONGODB_URI variable to your app in Glitch? It seems you wrote the code expecting this to work in Heroku.

I followed the instructions from this page https://www.freecodecamp.org/challenges/url-shortener-microservice, particularly this section “Pro Tip: Checkout this wiki article for tips on integrating MongoDB on Glitch.” But the wiki article references Heroku, not Glitch. So that’s probably the first mistake, as you mentioned. Either way, I’ve royally messed up my code so much that it doesn’t even work locally now, and I’m going to start over from the beginning. This time I’ll follow the template for Glitch that’s in the beta fcc url shortener. Hopefully I’ll be more successful there. Thanks for taking a look and giving it a try. :slight_smile:

I’ve been working with the same issue for the last few day’s.
My problem was in understanding how the promise was dealt with in mongodb. I finally solved it the other night and spent today making sure it wasn’t a fluke. Seem’s to work :slight_smile:
This is what they want, I think…