Since your E4 can at least able to connect to various WiFi networks that itself is a good sign (which if it was to be the problem could either a hardware or a software issue). Not getting actual online access being the problem is most likely a software issue.
Just some suggestions.
-- Your description is a possible indicator there's just some DNS issue.
https://en.wikipedia.org/wiki/Domain_Name_System
Basically DNS is what allows any of us to just type site names into our browsers than their actual IP address, a string of numbers. As a test, with your phone connected to your WiFi network, type in this IP address >> 89.146.4.148
That's one of the IP addresses for https:
www.startpage.com. If you can get to Startpage using just using that IP address, there's probably some issue with your ISP's DNS servers. Try installing this 'DNS Changer' app:
https://play.google.com/store/apps/details?id=com.burakgon.dnschanger
This app will allow you to change the DNS addresses you E4 rely upon. There are some presets you can select in the app, there are several public DNS services available, but I'm going to recommend using the custom option and use these two instead:
9.9.9.9
8.8.4.4
The first one is Quad9, a public DNS address with enhanced privacy and security:
https://arstechnica.com/information...ervice-blocks-malicious-domains-for-everyone/
The second is just one of Google's public DNS addresses.
Anyway, try and see if this makes a difference.
-- If changing DNS addresses doesn't solve the problem, you might want to try using an option in your Settings menu. If you go into Settings >> Wireless & networks >> More there's a 'Network settings reset' option. Keep in mind that this will clear all your network related settings so it'll wipe items like all saved WiFi networks and Bluetooth pairings. But it does return the networking settings back to their defaults.
-- If you're still having a problem getting online access, try wiping the system cache partition. The system cache resides in its own partition, so this won't affect any of your saved data and files. It also requires you to restart your E4 into its Recovery Mode. While running in Recovery Mode it's a text only interface so you need to use the indicated buttons to navigate through the different menus. Select the 'wipe cache partition' option, this should only take a few seconds and then just reboot your phone. Here's a guide on getting into Recovery Mode:
http://www.hardreset.info/devices/motorola/motorola-moto-e4/recovery-mode/