pocketbase: Error: listen tcp x.x.x.x:443: bind: cannot assign requested address
When I try to run
./pb serve --http="subdomain.domain.dev:80" --https="subdomain.domain.dev:443"
I get
listen tcp x.x.x.x:443: bind: cannot assign requested address
I’m missing something?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 40 (22 by maintainers)
I encountered the same issue on AWS EC2 (Ubuntu 22), and @jimafisk ’s reply solved my issue.
At first:
The fix:
Afterward:
To avoid using sudo, use
setcap
as described in official guideAdding
--https=...
generate a number of warning/error on the first run, though HTTPS does work in the browser.According to AWS doc, the private IP would not change unless the instance is terminated so this fix should keep on working(?):
”A private IPv4 address, regardless of whether it is a primary or secondary address, remains associated with the network interface when the instance is stopped and started, or hibernated and started, and is released when the instance is terminated.”
Thank you @ganigeorgiev that worked! ✔️
I ran
hostname -I
and that returned several IP addresses. The first was the ip4 address that I could see from the Digital Ocean dashboard that I had already tried unsuccessfully, but the second was an internal IP10.10.0.6
that worked! Just needed tovim /etc/hosts
:Just a couple of notes:
/etc/hosts
entry is still intactsystemctl
settings you described to work. Before the restart I could/root/pb/pocketbase serve --http="sub.mydomain.com:80" --https="sub.mydomain.com:443"
manually to start PocketBase but I couldn’tsystemctl enable pocketbase.service --now
to get it working in a persistent manner.Had the same issue of
bind: cannot assign requested address
when trying to serve with--https
Resolved with @ganigeorgiev and @jimafisk suggestions for adding network address IP to
/etc/hosts
. No caddy/nginx used 👍ok. now it’s working. There was couple issue with OracleCloud (adding http/https port on traffic in network configuration tab). Coupke hours later finally I can start to do something with that.
I’m sorry, I’m kinda new to setting up linux servers. I figured it out. I’ve checked ifconfig and got two entries there, one of which had
UP,BROADCAST,RUNNING,MULTICAST
flags and secondUP,LOOPBACK,RUNNING
. So I got the ip address from the first one and added it to/etc/hosts
like thisip-address domain
. Then I ran./pocketbase serve --http="subdomain.domain:80" --https="subdomain.domain:443"
and it worked. I checked it in browser and everything was good. Sorry for wasting your time and thank you for the great work!I think I might be able to help clear this up.
subdomain.domain.dev:443
, golang will resolve the DNS (only once) to get an IP and bind that IP.listen tcp x.x.x.x:443: bind: cannot assign requested address
- this error occurs when you try to bind to an IP that isn’t local. in linux, you can show the list of local IPs withhostname -I
.--standalone
.from the comments,
subdomain.domain.dev
doesn’t resolve to a local IP. hence the error.it’s especially important to note that binding to a domain will not work with ddns, since golang will resolve the DNS only once.
here’s some workarounds for @noxware:
caddy --from subdomain.domain.dev --to localhost:8090
(top of my head, see their docs)I highly recommend caddy.
pocketbas can also tackle it by always binding to 0.0.0.0 for https. or maybe separate the https argument into listen and domain. who knows, up to them.
personally, I’d drop https support. luckily i’m not in the pocketbase team 😉
It’s definitely the public one.
I tried with
--debug
before but I remember that it only showed some sql stuff. I’m gonna try luck with ngnix in a moment.