process.env.PORT 8120 by default?


#1

Hi guys!

It’s my 4th API microservice in Glitch. Today I’ve imported one of my projects from GitHub and it wasn’t running okay. I’ve tested anything and reviewed all the code. Then I’ve noticed that glitch was using port 8120 for process.env.PORT by default. In my last projects it was always using 3000. Is it a bug?!??


#2

Haven’t seen that one, myself at least. Try importing it into a new instance and see if it happens again? Does the repo happen to be public?


#3

Can you let us know the GitHub project if it’s public so we can try and reproduce. Thanks!


#4

Hi guys! This is the project I’ve imported and tested again. Don’t know why it listens by default on port 8120.
Can you help me understand that?


#5

Hah, this one was subtle but my eagle-eyed colleague, Emanuele, spotted the issue.

You were using: process.env.PORT | 8080, which is a Bitwise OR, 3000 | 8080 = 8120

What you want is the logical OR: process.env.PORT || 8080


#6

Hey folks! Sorry! It was the late night coding ahahahah… I’ve spent 4 hours around this situation! I owe you a beer when u come to Portugal! :wink: :beers:

Thank you for the quickest support in the world :wink: