Custom Domain for API

Changed port to 8000 and still getting the EADDRINUSE error unfortunately. I checked for availability on both port 8000 and 443 with sudo netstat -nltp | grep porthere, and neither are being used.

the parkingpage.namecheap.com is what that domain is.

Weird. I cleared all of the DNS records so I’m not sure why you would be seeing that. All I’m seeing is this on the page.

port should be 3000 for glitch, thats the port they use default. repl and others use something in the 80’s i believe

also, your domain just redirects me to google.

I honestly don’t know why that is. I cleared out all of the records and everything except for the A record pointing to the IP of my droplet. Could someone possibly have access to my Cloudflare account or something?

No one has access to your cloudflare most probably. Is your site on glitch or something else?

I’m using Digital Ocean for the VPS. The code that isn’t working is uploaded through Termius to the droplet.

@SS4PPHIRE I think I figured it out. I think that you are starting two instances of your app, or you are running app.listen() twice because your app mentions that it is running on port 8000, then it errors after that. If your code looks like this

app.listen(8000, ()=> console.log("running on port "+PORT))

Or something like that, it would return only that. But it seems you have it like this,

app.listen(8000, ()=> console.log("running on port "+PORT))
// listening again somewhere in your code.
app.listen(8000, ()=> console.log("running on port "+PORT))

So, that means there are two possible solutions. Make sure your package.json start script does not run it twice, and you are not running app.listen() twice.

Alternatively, you could use ps aux to look through the processes. Also, try going directly to the IP. If you are on Chrome, you may need to do this little trick. If you go there and there is no advance button, type this in no spaces, not on a text box. “thisisunsafe”. It should redirect you.

1 Like

I’m going to wipe my server and reinstall NPM and PM2. I may have messed something up beforehand. I’m not seeing app.listen twice, and there’s only one process, so I’m not sure.

Wiping it did the trick. I’m not getting any more errors. “App running on port 443”.

I’m still having the google issue though. I have no idea why it’s redirecting to google.

hmm. Did you put a 304 in your code?

I don’t know what that is, sorry. Pretty new to this.

A 304 status caches a redirect into the computer. So whenever you visit that endpoint, it will redirect you no matter what the code is.

I didn’t put anything like that in the code. Should I?

Don’t unless you are really good with Express, or if you really need it.

1 Like

Okay. What should I do to fix the google redirect?

Try clearing your cache, or try to log the requests.

Also, don’t append www to the begining of the domain. Just put the domain.